🎉 Initial Commit
This commit is contained in:
8
background.js
Normal file
8
background.js
Normal file
@@ -0,0 +1,8 @@
|
||||
chrome.tabs.onUpdated.addListener((tabId, changeInfo, tab) => {
|
||||
if (changeInfo.status === 'complete' && tab.url.includes("portal.azure.com")) {
|
||||
chrome.scripting.executeScript({
|
||||
target: { tabId: tabId },
|
||||
files: ['content.js']
|
||||
});
|
||||
}
|
||||
});
|
||||
43
content.js
Normal file
43
content.js
Normal file
@@ -0,0 +1,43 @@
|
||||
function selectGroupByType() {
|
||||
const intervalId = setInterval(() => {
|
||||
const dropdown = document.querySelector('[aria-label="Group by"]');
|
||||
if (dropdown) {
|
||||
console.log('Dropdown gefunden');
|
||||
dropdown.click();
|
||||
setTimeout(() => {
|
||||
const dropdownItems = document.querySelectorAll('.dropdown-item');
|
||||
if (dropdownItems.length > 0) {
|
||||
console.log('Dropdown-Items gefunden:', dropdownItems.length);
|
||||
const typeOption = Array.from(dropdownItems)
|
||||
.find(item => item.innerText && item.innerText.includes('Resource type'));
|
||||
if (typeOption) {
|
||||
console.log('Resource type Option gefunden');
|
||||
typeOption.click();
|
||||
clearInterval(intervalId); // Stop the interval once the option is selected
|
||||
} else {
|
||||
console.log('Resource type Option nicht gefunden');
|
||||
}
|
||||
} else {
|
||||
console.log('Keine Dropdown-Items gefunden');
|
||||
}
|
||||
}, 2000); // Wait for the dropdown to expand
|
||||
} else {
|
||||
console.log('Dropdown nicht gefunden');
|
||||
}
|
||||
}, 2000); // Check every 2 seconds
|
||||
}
|
||||
|
||||
// Run the function when the page is fully loaded
|
||||
window.addEventListener('load', () => {
|
||||
setTimeout(selectGroupByType, 3000); // Wait for 3 seconds
|
||||
});
|
||||
|
||||
// Observe DOM changes in case the dropdown loads later
|
||||
const observer = new MutationObserver(() => {
|
||||
selectGroupByType();
|
||||
});
|
||||
|
||||
observer.observe(document.body, {
|
||||
childList: true,
|
||||
subtree: true
|
||||
});
|
||||
19
manifest.json
Normal file
19
manifest.json
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"manifest_version": 3,
|
||||
"name": "Azure Group By Type",
|
||||
"version": "1.0",
|
||||
"description": "Automatically selects 'Group By Type' in the Azure portal.",
|
||||
"permissions": [
|
||||
"activeTab",
|
||||
"scripting"
|
||||
],
|
||||
"background": {
|
||||
"service_worker": "background.js"
|
||||
},
|
||||
"content_scripts": [
|
||||
{
|
||||
"matches": ["https://portal.azure.com/*"],
|
||||
"js": ["content.js"]
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user