Youtube and google regularly change your region based on your IP. This userscript automatically sets it to your preferred region instead.
< 腳本YouTube and Google region setter的回應
Edited the code slightly to use a YouTube URL parameter that has the region change persist, feel free to correct it if the syntax is incorrect:// ==UserScript==// @run-at document-start// @version 1.0.0// @name YouTube and Google region setter// @namespace https://github.com/emmaexe/userscripts// @author emmaexe// @description Youtube and google regularly change your region based on your IP. This userscript automatically sets it to your preferred region instead.// @license GPL-3.0-only// @homepageURL https://github.com/emmaexe/userscripts// @supportURL https://github.com/emmaexe/userscripts/issues// @include *://youtube.*/*// @include *://*.youtube.*/*// @include *://www.google.com/*// @exclude *://www.google.com/a/*// @icon https://raw.githubusercontent.com/emmaexe/userscripts/main/youtube-region-setter/assets/youtube-ico-32.png// @grant GM.registerMenuCommand// @grant GM.getValue// @grant GM.setValue// @downloadURL https://update.greasyfork.org/scripts/454052/YouTube%20and%20Google%20region%20setter.user.js// @updateURL https://update.greasyfork.org/scripts/454052/YouTube%20and%20Google%20region%20setter.meta.js// ==/UserScript==GM.registerMenuCommand('Set preferred youtube/google region', async () => { region = prompt('Please enter your preferred region:', 'GB'); await GM.setValue('region', region); window.location.reload();})async function main(){ let region = await GM.getValue('region', 'GB'); let oldUrl = location.href; let arr = oldUrl.split('?'); //original is "&gl=$" if (!(oldUrl.includes(`?persist_gl=1&gl=${region}`) || oldUrl.includes(`?persist_gl=1&gl=${region}`))) { if (arr.length > 1 && arr[1] !== '') { location.replace(oldUrl+`?persist_gl=1&gl=${region}`); } else { location.replace(oldUrl+`?persist_gl=1&gl=${region}`); } }}main();this should fix the issue with YouTube changing the region back, the region change persists in my testing
登入以回復
Edited the code slightly to use a YouTube URL parameter that has the region change persist, feel free to correct it if the syntax is incorrect:
// ==UserScript==
// @run-at document-start
// @version 1.0.0
// @name YouTube and Google region setter
// @namespace https://github.com/emmaexe/userscripts
// @author emmaexe
// @description Youtube and google regularly change your region based on your IP. This userscript automatically sets it to your preferred region instead.
// @license GPL-3.0-only
// @homepageURL https://github.com/emmaexe/userscripts
// @supportURL https://github.com/emmaexe/userscripts/issues
// @include *://youtube.*/*
// @include *://*.youtube.*/*
// @include *://www.google.com/*
// @exclude *://www.google.com/a/*
// @icon https://raw.githubusercontent.com/emmaexe/userscripts/main/youtube-region-setter/assets/youtube-ico-32.png
// @grant GM.registerMenuCommand
// @grant GM.getValue
// @grant GM.setValue
// @downloadURL https://update.greasyfork.org/scripts/454052/YouTube%20and%20Google%20region%20setter.user.js
// @updateURL https://update.greasyfork.org/scripts/454052/YouTube%20and%20Google%20region%20setter.meta.js
// ==/UserScript==
GM.registerMenuCommand('Set preferred youtube/google region', async () => {
region = prompt('Please enter your preferred region:', 'GB');
await GM.setValue('region', region);
window.location.reload();
})
async function main(){
let region = await GM.getValue('region', 'GB');
let oldUrl = location.href;
let arr = oldUrl.split('?');
//original is "&gl=$"
if (!(oldUrl.includes(`?persist_gl=1&gl=${region}`) || oldUrl.includes(`?persist_gl=1&gl=${region}`))) {
if (arr.length > 1 && arr[1] !== '') {
location.replace(oldUrl+`?persist_gl=1&gl=${region}`);
} else {
location.replace(oldUrl+`?persist_gl=1&gl=${region}`);
}
}
}
main();
this should fix the issue with YouTube changing the region back, the region change persists in my testing