-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontent.js
25 lines (21 loc) · 827 Bytes
/
content.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
function modifyButtonUrlsAndText() {
const buttons = document.querySelectorAll("a"); // Select all anchor elements
buttons.forEach(button => {
if (button.href && button.href.includes("audiobook-overdrive")) {
button.href = button.href.replace("audiobook-overdrive", "audiobook-mp3");
button.textContent = "Download .odm file";
console.log(`Modified URL and text: ${button.href} - ${button.textContent}`);
}
});
}
// Run the function initially
modifyButtonUrlsAndText();
// Observe DOM changes to handle dynamically loaded content
const observer = new MutationObserver(() => {
modifyButtonUrlsAndText();
});
// Start observing changes in the body
observer.observe(document.body, {
childList: true, // Listen for added/removed nodes
subtree: true // Include all descendant nodes
});