commit e4b41ab15b16d37b9c58cbfd8c56b8f354068fc4 Author: k3y0708 Date: Mon Mar 31 23:41:36 2025 +0200 🎉 Initial Commit diff --git a/background.js b/background.js new file mode 100644 index 0000000..019d0a6 --- /dev/null +++ b/background.js @@ -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'] + }); + } +}); diff --git a/content.js b/content.js new file mode 100644 index 0000000..dccec68 --- /dev/null +++ b/content.js @@ -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 +}); diff --git a/manifest.json b/manifest.json new file mode 100644 index 0000000..40e7f40 --- /dev/null +++ b/manifest.json @@ -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"] + } + ] +}