Guest User

this?

a guest
Aug 7th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.29 KB | None | 0 0
  1. // ==UserScript==
  2. // @name Get me Old Youtube
  3. // @namespace http://greasyfork.org/en/scripts/32906
  4. // @version 1.2.3
  5. // @description Sets a Cookie which loads the old Youtube layout (as long as available)
  6. // @author Artain
  7. // @match *://www.youtube.com/*
  8. // @exclude *://www.youtube.com/tv*
  9. // @exclude *://www.youtube.com/embed/*
  10. // @exclude *://www.youtube.com/live_chat*
  11. // @exclude *://www.youtube.com/feed/subscriptions?flow=2*
  12. // @run-at document-start
  13. // @homepageURL http://greasyfork.org/en/scripts/32906
  14. // @license https://creativecommons.org/licenses/by-sa/4.0/
  15. // @grant none
  16. // ==/UserScript==
  17.  
  18. (function() {
  19. 'use strict';
  20.  
  21. function start() {
  22. var cookie = getPref(),
  23. pref = "f6=8";
  24. if(cookie === "fIsAlreadySet") {
  25. return;
  26. } else if(cookie !== "noPref"){
  27. for(var i = 0; i < cookie.length; ++i) {
  28. pref = pref + "&" + cookie[i].key + "=" + cookie[i].value;
  29. }
  30. }
  31. changePref(pref);
  32. }
  33.  
  34. function changePref(values) {
  35. var d = new Date();
  36. d.setTime(d.getTime() + (100*24*60*60*1000));
  37. var expires = "expires="+ d.toUTCString();
  38. document.cookie = "PREF=" + values + ";" + expires + ";domain=.youtube.com;hostonly=false;path=/";
  39. location.reload();
  40. }
  41.  
  42. function getPref() {
  43. var cookie = document.cookie,
  44. splitC = cookie.split(";");
  45. for(var i = 0; i < splitC.length; ++i) {
  46. if(splitC[i].trim().indexOf("PREF") === 0) {
  47. if(splitC[i].trim().indexOf("f6=8") > -1) {
  48. return "fIsAlreadySet";
  49. }
  50. var c = [],
  51. splitValues = splitC[i].substring(5).split("&");
  52. for(var k = 0; k < splitValues.length; ++k) {
  53. var splitV = splitValues[k].split("=");
  54. if(splitV[0] !== "f6") {
  55. var kv = {};
  56. kv.key = splitV[0];
  57. kv.value = splitV[1];
  58. c.push(kv);
  59. }
  60. }
  61. return c;
  62. }
  63. }
  64. return "noPref";
  65. }
  66. start();
  67. })();
Add Comment
Please, Sign In to add comment