Youtube - Restore Classic

If youtube is in the new 2017 YouTube Material Redesign, automatically restore classic view

اعتبارا من 12-11-2017. شاهد أحدث إصدار.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

ستحتاج إلى تثبيت إضافة مثل Stylus لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتتمكن من تثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

(لدي بالفعل مثبت أنماط للمستخدم، دعني أقم بتثبيته!)

// ==UserScript==
// @name         Youtube - Restore Classic
// @version      1.0.2
// @description  If youtube is in the new 2017 YouTube Material Redesign, automatically restore classic view
// @author       Cpt_mathix
// @match        https://www.youtube.com
// @include      https://www.youtube.com/*
// @license      GPL version 2 or any later version; http://www.gnu.org/licenses/gpl-2.0.txt
// @namespace    https://greasyfork.org/users/16080
// @run-at       document-start
// @grant        none
// @noframes
// ==/UserScript==

(function() {
    replaceCookie("PREF");

    function replaceCookie(name) {
        if (document.cookie) {
            var match = document.cookie.match(RegExp('(?:^|;\\s*)' + name + '=([^;]*)'));
            if (match && match[1]) {
                match = match[1];
                console.log("current PREF cookie: " + match);
                if (match.search(/f6=(8|9)(&|;)/) === -1) {
                    if (match.search(/f6=.+(&|;)/) === -1) {
                        document.cookie = "PREF=" + match + "&f6=8" + ";path=/;domain=.youtube.com";
                    } else if (match.search(/f6=.+(&|;)/) !== -1) {
                        document.cookie = "PREF=" + match.replace(/f6=.+(&|;)/, 'f6=8&') + ";path=/;domain=.youtube.com";
                    }
                    location.reload();
                }
            } else {
                console.log("PREF cookie not found");
            }
        } else {
            console.log("document.cookie not supported for your browser or you do not allow cookies at all");
        }
    }
})();