Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name YT - Old design
- // @namespace 4c5725cd7d4b94b6f1784e759d5a43fbdd917971
- // @version 0.2
- // @description Activates the old YouTube design without messing with your other settings
- // @author /u/AyrA_ch
- // @match https://www.youtube.com/*
- // @match http://www.youtube.com/*
- // @match https://youtube.com/*
- // @match http://youtube.com/*
- // @grant none
- // @run-at document-start
- // ==/UserScript==
- // Changelog
- // 0.2 Changed title to match other scripts
- // 0.1 Initial Version
- (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=/";
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement