-
-
Save hermesthecat/f4fbaacf08f98610d49f29045e2ba135 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This script is not mine. For source look into here: | |
// https://cable.ayra.ch/tampermonkey/view.php?script=youtube_old_design.user.js | |
(function () { | |
var getDesignCookie = function (cookie) { | |
//Find existing preferences | |
var prefs = cookie.split("; ").filter(function (v) { | |
return v.indexOf("PREF=") === 0; | |
})[0]; | |
//No preferences, return new ones with design setting | |
if (!prefs) { | |
console.log("prefs not set in cookie"); | |
return "PREF=f6=8"; | |
} | |
//Process all settings | |
var entries = prefs.substr(5).split('&'); | |
var set = false; | |
for (var i = 0; i < entries.length; i++) { | |
if (entries[i].indexOf("f6=") === 0) { | |
set = true; | |
//Set the old design flag | |
var value = +entries[i].substr(3); | |
if ((value & 8) === 0) { | |
console.log("Activating old design and reloading..."); | |
entries[i] = "f6=" + (value | 8); | |
window.setTimeout(location.reload.bind(location,true),100); | |
} | |
else{ | |
console.log("Old design already active. Doing nothing"); | |
} | |
} | |
} | |
//Design flag setting doesn't exists. Adding it instead | |
if (!set) { | |
console.log("Activating old design and reloading..."); | |
entries.push("f6=8"); | |
window.setTimeout(location.reload.bind(location,true),100); | |
} | |
//Build cookie | |
return "PREF=" + entries.join('&'); | |
}; | |
//Update cookie | |
document.cookie = getDesignCookie(document.cookie) + ";domain=.youtube.com;path=/"; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment