Skip to content

Instantly share code, notes, and snippets.

@ivankolesnik
Created July 15, 2018 22:03
Show Gist options
  • Save ivankolesnik/a570d727dde4ae62663f41921f181d42 to your computer and use it in GitHub Desktop.
Save ivankolesnik/a570d727dde4ae62663f41921f181d42 to your computer and use it in GitHub Desktop.
// 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