Allow Css on specific domain?
youtube use a weird function to change the url location,blow code may work but not so perfectly
// ==UserScript==
// @name Allow_only_on_main_of_youtube
// @match https://www.youtube.com/
// @grant GM_addStyle
// @run-at document-start
// ==/UserScript==
const style = GM_addStyle ( `
a{color:red!important}
`);
window.addEventListener('yt-navigate-finish', function (){
if (document.location.search!=""){
style.innerHTML = "";
}else{
style.innerHTML = `a{color:red!important}`;
}
});
I didn't know it could be hard to manage. as you mentioned, the code is not working fluently. however Thanks for spare your time for finding a solution. :)
Also try yt-navigate-start
instead of yt-navigate-finish
@wOxxOm as I'd tested, yt-navigate-start
works better than the yt-navigate-finish
, however still unstable to use though.
Thanks for the suggestion :)
Allow Css on specific domain?
I'd convert give custom css only on "https://www.youtube.com/" but not other domains such as starts with "https://www.youtube.com/results*" or "https://www.youtube.com/watch*"
as the page do not refresh when move on another youtube site from the "www.youtube.com/" font color does not changed to red with the code.