Advertisement
Guest User

Untitled

a guest
Dec 6th, 2019
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.85 KB | None | 0 0
  1. // ==UserScript==
  2. // @name YT - Old design
  3. // @namespace 4c5725cd7d4b94b6f1784e759d5a43fbdd917971
  4. // @version 0.2
  5. // @description Activates the old YouTube design without messing with your other settings
  6. // @author /u/AyrA_ch
  7. // @match https://www.youtube.com/*
  8. // @match http://www.youtube.com/*
  9. // @match https://youtube.com/*
  10. // @match http://youtube.com/*
  11. // @grant none
  12. // @run-at document-start
  13. // ==/UserScript==
  14.  
  15. // Changelog
  16. // 0.2 Changed title to match other scripts
  17. // 0.1 Initial Version
  18.  
  19. (function () {
  20. var getDesignCookie = function (cookie) {
  21. //Find existing preferences
  22. var prefs = cookie.split("; ").filter(function (v) {
  23. return v.indexOf("PREF=") === 0;
  24. })[0];
  25. //No preferences, return new ones with design setting
  26. if (!prefs) {
  27. console.log("prefs not set in cookie");
  28. return "PREF=f6=8";
  29. }
  30. //Process all settings
  31. var entries = prefs.substr(5).split('&');
  32. var set = false;
  33. for (var i = 0; i < entries.length; i++) {
  34. if (entries[i].indexOf("f6=") === 0) {
  35. set = true;
  36. //Set the old design flag
  37. var value = +entries[i].substr(3);
  38. if ((value & 8) === 0) {
  39. console.log("Activating old design and reloading...");
  40. entries[i] = "f6=" + (value | 8);
  41. window.setTimeout(location.reload.bind(location,true),100);
  42. }
  43. else{
  44. console.log("Old design already active. Doing nothing");
  45. }
  46. }
  47. }
  48. //Design flag setting doesn't exists. Adding it instead
  49. if (!set) {
  50. console.log("Activating old design and reloading...");
  51. entries.push("f6=8");
  52. window.setTimeout(location.reload.bind(location,true),100);
  53. }
  54. //Build cookie
  55. return "PREF=" + entries.join('&');
  56. };
  57. //Update cookie
  58. document.cookie = getDesignCookie(document.cookie) + ";domain=.youtube.com;path=/";
  59. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement