34 lines
1.1 KiB
JavaScript
34 lines
1.1 KiB
JavaScript
|
|
// content.js
|
|
const blacklistedDomains = [
|
|
"linkedin.com",
|
|
// Add more domains to the blacklist
|
|
];
|
|
|
|
function disableBlacklistedLinks() {
|
|
const elements = document.querySelectorAll('a, button');
|
|
|
|
elements.forEach(element => {
|
|
const href = element.href || element.onclick?.toString();
|
|
|
|
if (href) {
|
|
const url = new URL(href, window.location.origin);
|
|
|
|
if (blacklistedDomains.some(domain => url.hostname.includes(domain))) {
|
|
element.style.pointerEvents = 'none';
|
|
element.style.opacity = '0.5';
|
|
element.onclick = null;
|
|
element.setAttribute('disabled', 'disabled');
|
|
element.title = 'This link has been disabled due to blacklisting';
|
|
element.textContent = 'This link has been disabled due to blacklisting';
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
// Run the function when the page loads
|
|
disableBlacklistedLinks();
|
|
|
|
// Use a MutationObserver to handle dynamically added content
|
|
const observer = new MutationObserver(disableBlacklistedLinks);
|
|
observer.observe(document.body, { childList: true, subtree: true }); |