Retour à l'ancienne interface Youtube

Sets de Cookie pour chargement ancienne interface Youtube

当前为 2017-11-09 提交的版本,查看 最新版本

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