mirror of
https://gitlab.com/arnekeller/yt-addiction-control.git
synced 2024-11-23 00:45:00 +00:00
Merge manifest.json
This commit is contained in:
commit
39fdbd3ac1
@ -2,7 +2,7 @@
|
|||||||
"description": "Enables you to fight your youtube addiction by hiding video suggestions and related 'features' of YouTube's website. If you really want to, you can temporarily unhide those elements.",
|
"description": "Enables you to fight your youtube addiction by hiding video suggestions and related 'features' of YouTube's website. If you really want to, you can temporarily unhide those elements.",
|
||||||
"manifest_version": 2,
|
"manifest_version": 2,
|
||||||
"name": "YT addiction control",
|
"name": "YT addiction control",
|
||||||
"version": "0.1",
|
"version": "0.1.1",
|
||||||
"homepage_url": "https://gitlab.com/arnekeller/yt-addiction-control",
|
"homepage_url": "https://gitlab.com/arnekeller/yt-addiction-control",
|
||||||
|
|
||||||
"icons": {
|
"icons": {
|
||||||
|
@ -6,7 +6,7 @@ Array.from(document.getElementsByClassName(STYLE_CLASS)).forEach((e) => {
|
|||||||
e.remove();
|
e.remove();
|
||||||
});
|
});
|
||||||
|
|
||||||
let ytacCSS = {
|
window.ytacCSS = {
|
||||||
"sidebar": "#related",
|
"sidebar": "#related",
|
||||||
"comments": "#comments",
|
"comments": "#comments",
|
||||||
"endscreen": ".videowall-endscreen",
|
"endscreen": ".videowall-endscreen",
|
||||||
@ -15,24 +15,37 @@ let ytacCSS = {
|
|||||||
"other": "#newness-dot, .ytp-spinner"
|
"other": "#newness-dot, .ytp-spinner"
|
||||||
};
|
};
|
||||||
|
|
||||||
const INVISIBLE = " { display: none !important; }"
|
const INVISIBLE = " { display: none !important; }";
|
||||||
|
|
||||||
let head = document.getElementsByTagName('head')[0];
|
function addCSS(key) {
|
||||||
for (key of Object.keys(ytacCSS)) {
|
if (document.getElementById("ytac" + key) !== null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let head = document.getElementsByTagName('head')[0];
|
||||||
let e = document.createElement('style');
|
let e = document.createElement('style');
|
||||||
e.setAttribute('type', 'text/css');
|
e.setAttribute('type', 'text/css');
|
||||||
e.setAttribute("class", STYLE_CLASS);
|
e.setAttribute("class", STYLE_CLASS);
|
||||||
e.setAttribute("id", "ytac" + key);
|
e.setAttribute("id", "ytac" + key);
|
||||||
|
|
||||||
if ('textContent' in e) {
|
if ('textContent' in e) {
|
||||||
e.textContent = ytacCSS[key] + INVISIBLE;
|
e.textContent = window.ytacCSS[key] + INVISIBLE;
|
||||||
} else {
|
} else {
|
||||||
e.styleSheet.cssText = ytacCSS[key] + INVISIBLE;
|
e.styleSheet.cssText = window.ytacCSS[key] + INVISIBLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
head.appendChild(e);
|
head.appendChild(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function addClickListeners(key) {
|
||||||
|
for (el of document.querySelectorAll(window.ytacCSS[key])) {
|
||||||
|
el.addEventListener("click", (e) => addCSS(key));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (key of Object.keys(window.ytacCSS)) {
|
||||||
|
addCSS(key);
|
||||||
|
}
|
||||||
|
|
||||||
// browser action listener
|
// browser action listener
|
||||||
|
|
||||||
// Listen for messages from the background script.
|
// Listen for messages from the background script.
|
||||||
@ -47,15 +60,19 @@ window.ytacListener = (message) => {
|
|||||||
} else if (message.command == "sidebar") {
|
} else if (message.command == "sidebar") {
|
||||||
console.log("[YTAC] showing video sidebar");
|
console.log("[YTAC] showing video sidebar");
|
||||||
document.getElementById("ytacsidebar").remove();
|
document.getElementById("ytacsidebar").remove();
|
||||||
|
addClickListeners("sidebar");
|
||||||
} else if (message.command == "invideo") {
|
} else if (message.command == "invideo") {
|
||||||
console.log("[YTAC] showing in-video suggestions");
|
console.log("[YTAC] showing in-video suggestions");
|
||||||
document.getElementById("ytacinvideo").remove();
|
document.getElementById("ytacinvideo").remove();
|
||||||
|
addClickListeners("invideo");
|
||||||
} else if (message.command == "endscreen") {
|
} else if (message.command == "endscreen") {
|
||||||
console.log("[YTAC] showing endscreen");
|
console.log("[YTAC] showing endscreen");
|
||||||
document.getElementById("ytacendscreen").remove();
|
document.getElementById("ytacendscreen").remove();
|
||||||
|
addClickListeners("endscreen");
|
||||||
} else if (message.command == "notification") {
|
} else if (message.command == "notification") {
|
||||||
console.log("[YTAC] showing notification bell");
|
console.log("[YTAC] showing notification bell");
|
||||||
document.getElementById("ytacnotification").remove();
|
document.getElementById("ytacnotification").remove();
|
||||||
|
addClickListeners("notification");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
browser.runtime.onMessage.addListener(window.ytacListener);
|
browser.runtime.onMessage.addListener(window.ytacListener);
|
||||||
@ -81,3 +98,13 @@ function modifyThings() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
modifyThings();
|
modifyThings();
|
||||||
|
|
||||||
|
// attempt to hide the notification count in the title
|
||||||
|
|
||||||
|
function hideNotificationCount() {
|
||||||
|
let a = document.getElementsByTagName("title")[0];
|
||||||
|
if (a.innerText.match("^\\(\\d+\\).*")) {
|
||||||
|
a.innerText = a.innerText.substr(a.innerText.indexOf(")") + 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
setInterval(hideNotificationCount, 1000);
|
Loading…
Reference in New Issue
Block a user