// ==UserScript==
// @name YouTube Old Layout
// @name:pt-BR Layout Antigo do YouTube
// @name:ar YouTube Old Layout
// @name:bg YouTube Old Layout
// @name:cs YouTube Old Layout
// @name:da YouTube Old Layout
// @name:de YouTube Old Layout
// @name:el YouTube Old Layout
// @name:eo YouTube Old Layout
// @name:es YouTube Old Layout
// @name:fi YouTube Old Layout
// @name:fr YouTube Old Layout
// @name:fr-CA YouTube Old Layout
// @name:he YouTube Old Layout
// @name:hu YouTube Old Layout
// @name:id YouTube Old Layout
// @name:it YouTube Old Layout
// @name:ja YouTube Old Layout
// @name:ko YouTube Old Layout
// @name:nb YouTube Old Layout
// @name:nl YouTube Old Layout
// @name:pl YouTube Old Layout
// @name:ro YouTube Old Layout
// @name:ru YouTube Old Layout
// @name:sk YouTube Old Layout
// @name:sr YouTube Old Layout
// @name:sv YouTube Old Layout
// @name:th YouTube Old Layout
// @name:tr YouTube Old Layout
// @name:uk YouTube Old Layout
// @name:vi YouTube Old Layout
// @name:zh-CN YouTube Old Layout
// @name:zh-TW YouTube Old Layout
// @description Permanently recover the old YouTube layout!
// @description:pt-BR Recupere permanentemente o antigo layout do YouTube!
// @description:ar استعادة تخطيط يوتيوب القديم بشكل دائم!
// @description:bg Задължително възстановете старото оформление на YouTube!
// @description:cs Trvale obnovit původní rozložení YouTube!
// @description:da Gendan det gamle YouTube-layout permanent!
// @description:de Stellen Sie das alte YouTube-Layout dauerhaft wieder her!
// @description:el Ανακατέψτε οριστικά την παλιά διάταξη του YouTube!
// @description:eo Konstante reakiri la malnovan YouTube-aranĝon!
// @description:es ¡Recupere permanentemente el antiguo diseño de YouTube!
// @description:fi Palauta vanha YouTube-asettelu pysyvästi!
// @description:fr Récupérez définitivement l'ancienne mise en page YouTube!
// @description:fr-CA Récupérez définitivement l'ancienne mise en page YouTube!
// @description:he השחזר לצמיתות את הפריסה הישנה של YouTube!
// @description:hu Véglegesen helyreállíthatja a régi YouTube-elrendezést!
// @description:id Pulihkan tata letak YouTube lama secara permanen!
// @description:it Ripristina definitivamente il vecchio layout di YouTube!
// @description:ja 古いYouTubeレイアウトを完全に復元します!
// @description:ko 기존 YouTube 레이아웃을 영구적으로 복구하십시오!
// @description:nb Gjenopprett den gamle YouTube-layouten permanent!
// @description:nl Herstel permanent de oude YouTube-lay-out!
// @description:pl Trwale przywróć stary układ YouTube!
// @description:ro Recuperați definitiv vechea structură YouTube!
// @description:ru Навсегда восстановить старый макет YouTube!
// @description:sk Natrvalo obnovte staré rozloženie YouTube!
// @description:sr Trajno oporavite stari izgled YouTubea!
// @description:sv Återställ den gamla YouTube-layouten permanent!
// @description:th กู้คืนเค้าโครง YouTube แบบเก่าอย่างถาวร!
// @description:tr Eski YouTube düzenini kalıcı olarak kurtarın!
// @description:uk Постійно відновіть старий макет YouTube!
// @description:vi Khôi phục vĩnh viễn bố cục YouTube cũ!
// @description:zh-CN 永久恢复旧的YouTube布局!
// @description:zh-TW 永久恢復舊的YouTube佈局!
// @namespace
https://greasyfork.org/users/152924
// @homepageURL
https://greasyfork.org/scripts/402219
// @supportURL
https://greasyfork.org/scripts/402219/feedback
// @author Punisher
// @version 1.3.r
// @date 2020-06-16
// @compatible chrome
// @compatible firefox
// @compatible opera
// @compatible safari
// @license CC BY-NC-ND 4.0 International.
https://creativecommons.org/licenses/by-nc-nd/4.0/
// @include
http://www.youtube.com/*
// @include
https://www.youtube.com/*
// @grant none
// @run-at document-start
// ==/UserScript==
(function() {
var date = new Date();
date.setTime(date.getTime());
var targetPrefs={'f5':'30030','f6':'8'};
var prefStr=document.cookie.split(' ').filter(o=>o.indexOf('PREF=')!==-1)[0] || 'PREF=';
var prefEntries=prefStr.substr(5).split('&');
var found=false;
var changed=false;
for (var i=0; i<prefEntries.length; i++) {
for(let [key,value] of Object.entries(targetPrefs)) {
var found=false;
for (var i=0; i<prefEntries.length; i++) {
if (prefEntries
.indexOf(key) === 0) {
found=true;
if (prefEntries.substr(key.length+1)!==value) {
prefEntries=value;
changed=true;
}
}
}
if (!found) {
prefEntries.push(key+'='+value);
changed=true;
}
}
}
window.addEventListener("spfdone", function(e) {
if(!document.getElementById("content").classList.contains('content-alignment')){
document.getElementById('content').classList.add('content-alignment');
}
});
window.addEventListener("load", function(event) {
if(!document.getElementById("content").classList.contains('content-alignment')){
document.getElementById('content').classList.add('content-alignment');
}
});
if (changed) {
var newCookie='PREF='+prefEntries.join('&')+';domain=.youtube.com;path=/';
document.cookie=newCookie;
window.setTimeout(location.reload.bind(location,true),100);
}
})();