您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Automatically changes location to preferred country.
// ==UserScript== // @name YouTube Location // @namespace https://github.com/joshcangit // @description Automatically changes location to preferred country. // @author joshcangit // @homepageURL https://gf.qytechs.cn/en/scripts/424522-youtube-location // @version 1.7 // @include *://youtube.com/* // @include *://*.youtube.com/* // @exclude *://youtube.com/embed/* // @exclude *://*.youtube.com/embed/* // ==/UserScript== const Cookie = function(cookieName, cookieDomain) { this.name = cookieName, this.domain = cookieDomain, this.read = function() { let data = document.cookie.match('(^|[^;]+)\\s*' + this.name + '\\s*=\\s*([^;]+)'); return data ? data.pop() : null; }, // https://stackoverflow.com/a/25490531 this.remove = function() { while (document.cookie.includes(this.name)) { document.cookie = encodeURIComponent(this.name) + "=; expires=Thu, 01 Jan 1970 00:00:00 GMT" + (this.domain ? "; domain=" + this.domain : ""); } }, // https://stackoverflow.com/a/30387077 this.edit = function(param, value) { let array = this.read().split('&'); let fullstr = param+value; let index = array.findIndex(element => element.includes(param)); // https://stackoverflow.com/a/52124191 if (index === -1) { array.push(fullstr); } else if (array[index] !== fullstr) { array[index] = fullstr; } else fullstr = null; this.string = array.join('&'); return fullstr ? this : null; }, this.update = function(input) { let string = this.string ? this.string : input; while (string) { document.cookie = encodeURIComponent(this.name) + '=' + string + (this.domain ? "; domain=" + this.domain : ""); location.reload(); string = null; } } } let regex = /[?&]gl=\w+(&tab=\w+)*/; if (window.location.href.match(regex)) { let url = window.location.href.replace(regex, ''); if (url) window.location.replace(url); } let cname = new Cookie('s_gl', '.youtube.com'); cname.remove(); // delete cookie cname = null; let cpref = new Cookie('PREF', '.youtube.com'); // cookie storing preferences cpref.edit('gl=', 'US').update(); // overwrite cookie with country code cpref = null;
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址