Repository navigation
Expand file tree
/
Copy pathbackground.js
More file actions
52 lines (52 loc) · 1.79 KB
/
Copy pathbackground.js
File metadata and controls
52 lines (52 loc) · 1.79 KB
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// background.js
chrome.runtime.onMessage.addListener(function(message, sender, sendResponse) {
if (message.injectDislikeScript) {
chrome.scripting.executeScript({
target: { tabId: sender.tab.id },
function: injectDislikeScript
});
}
});
function injectDislikeScript() {
// Change background color
document.body.style.backgroundColor = "#0F0F0F";
// Change text color
document.body.style.color = "#FFFFFF";
// Apply Comic Sans MS font
document.body.style.fontFamily = "Comic Sans MS, cursive, sans-serif";
// Make first two characters of every word bold
const textElements = document.querySelectorAll("*");
textElements.forEach(element => {
element.innerHTML = element.innerHTML.replace(/\b(\w{2})/g, '<strong>$1</strong>');
});
// Replace logo
const logoElement = document.querySelector(".logo-selector");
if (logoElement) {
logoElement.src = chrome.runtime.getURL("MO.jpg");
}
// Replace title
document.title = "MyOutlet";
// Restore dislike functionality (you need to implement this part)
function handleDislikeClick(event) {
const dislikeButton = event.target;
const contentId = dislikeButton.getAttribute("data-content-id"); // Replace with actual attribute name
fetch("https://api.example.com/dislikes", {
method: "POST",
headers: {
"Content-Type": "application/json",
// Include any required authentication headers
},
body: JSON.stringify({ contentId: contentId }) // Replace with actual payload
})
.then(response => {
if (response.ok) {
// Dislike registered successfully, update UI as needed
} else {
// Handle error scenario
}
})
.catch(error => {
// Handle network or other errors
});
}
}