Retour à l'ancienne interface Youtube

Sets de Cookie pour chargement ancienne interface Youtube

当前为 2018-02-16 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Retour à l'ancienne interface Youtube
  3. // @namespace https://www.youtube.com/
  4. // @version 1.2.3
  5. // @description Sets de Cookie pour chargement ancienne interface Youtube
  6. // @copyright Okaïdo53
  7. // @author Okaïdo53
  8. // @Secure Okaïdo53
  9. // @compatible firefox
  10. // @compatible chrome
  11. // @compatible opera
  12. // @compatible Safari
  13. // @icon https://www.youtube.com/yts/img/yt_1200-vfl4C3T0K.png
  14. // @iconURL https://www.youtube.com/yts/img/yt_1200-vfl4C3T0K.png
  15. // @defaulticon https://www.youtube.com/yts/img/yt_1200-vfl4C3T0K.png
  16. // @icon64 https://www.youtube.com/yts/img/yt_1200-vfl4C3T0K.png
  17. // @icon64URL https://www.youtube.com/yts/img/yt_1200-vfl4C3T0K.png
  18. // @match *://www.youtube.com/*
  19. // @exclude *://www.youtube.com/tv*
  20. // @exclude *://www.youtube.com/embed/*
  21. // @exclude *://www.youtube.com/live_chat*
  22. // @require https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js
  23. // @homepage https://greasyfork.org/fr/scripts/34823-retour-%C3%A0-l-ancienne-interface-youtube
  24. // @homepageURL https://gist.github.com/Okaido53/668bd6649fab779b130c7eaaf2e6986c
  25. // @supportURL https://productforums.google.com/forum/#!home
  26. // @contributionURL https://www.paypal.com/
  27. // @run-at document-start
  28. // @run-at document-end
  29. // @run-at document-body
  30. // @run-at document-end
  31. // @run-at document-idle
  32. // @run-at context-menu
  33. // @connect <value>
  34. // @nocompat Chrome
  35. // @noframes
  36. // @grant none
  37. // @grant GM_setClipboard
  38. // @grant unsafeWindow
  39. // @grant GM_deleteValue
  40. // @grant GM_getValue
  41. // @grant GM_setValue
  42. // @grant GM_xmlhttpRequest
  43. // @grant window.focus
  44. // @grant window.close
  45. // @unwrap
  46. // @license GPL v3
  47. // ==/UserScript==
  48.  
  49. (function() {
  50. 'use strict';
  51.  
  52. function start() {
  53. var cookie = getPref(),
  54. pref = "f6=8";
  55. if(cookie === "fIsAlreadySet") {
  56. return;
  57. } else if(cookie !== "noPref"){
  58. for(var i = 0; i < cookie.length; ++i) {
  59. pref = pref + "&" + cookie[i].key + "=" + cookie[i].value;
  60. }
  61. }
  62. changePref(pref);
  63. }
  64. function changePref(values) {
  65. var d = new Date();
  66. d.setTime(d.getTime() + (100*24*60*60*1000));
  67. var expires = "expires="+ d.toUTCString();
  68. document.cookie = "PREF=" + values + ";" + expires + ";domain=.youtube.com;hostonly=false;path=/";
  69. location.reload();
  70. }
  71.  
  72. function getPref() {
  73. var cookie = document.cookie,
  74. splitC = cookie.split(";");
  75. for(var i = 0; i < splitC.length; ++i) {
  76. if(splitC[i].trim().indexOf("PREF") === 0) {
  77. if(splitC[i].trim().indexOf("f6=8") > -1) {
  78. return "fIsAlreadySet";
  79. }
  80. var c = [],
  81. splitValues = splitC[i].substring(5).split("&");
  82. for(var k = 0; k < splitValues.length; ++k) {
  83. var splitV = splitValues[k].split("=");
  84. if(splitV[0] !== "f6") {
  85. var kv = {};
  86. kv.key = splitV[0];
  87. kv.value = splitV[1];
  88. c.push(kv);
  89. }
  90. }
  91. return c;
  92. }
  93. }
  94. return "noPref";
  95. }
  96. start();
  97. })();