Youtube Persist Worldwide

By Burn Last update Nov 24, 2009 — Installed 2,040 times. Daily Installs: 28, 9, 16, 12, 8, 9, 2, 4, 5, 5, 3, 5, 3, 9, 4, 4, 8, 6, 2, 7, 2, 7, 3, 1, 19, 15, 7, 12, 8, 39, 14, 14

There are 19 previous versions of this script.

// ==UserScript==
// @name           Youtube Persist Worldwide
// @namespace      http://userscripts.org/scripts/show/33551
// @description    Force youtube to use worldwide contents
// @include        http://*.youtube.com/*
// @version        0.4.3
// @author         Burn
// ==/UserScript==


function ForceWorldwideContents() {
	var ClassN = document.body.className.toString();
	var RE_lang = /[a-z]{2}_[A-Z]{2}/;
	var lang = ClassN.match(RE_lang).toString();
	GM_log(">"+lang+"<");
	var stri = "";
	switch (lang) {
		case "it_IT": 
			stri = "a livello mondiale";
		break;
		case "de_DE":
			stri = "weltweit";
		break;
		case "en_GB":
		case "en_US":
			stri = "worldwide";
		break;
		case "es_ES":
			stri = "mundial";
		break;
		case "es_MX":
			stri = "en todo el mundo";
		break;
		case "fr_FR":
			stri = "dans le monde entier";
		break;
		case "nl_NL":
			stri = "wereldwijd";
		break;
		case "pl_PL":
			stri = "cały świat";
		break;
		case "he_IL":
			stri = "כלל עולמי (כולם)";
		break;
		case "ru_RU":
			stri = "По всему миру";
		break;
		case "bg_BG":
			stri = "от цял свят";
		break;
		case "":
		default:
			GM_log('Language not found: ->'+lang+'<-');
			return false;
	}
	GM_log(stri);
	var hrefs = document.evaluate(".//strong[@class='region-title']",document.body,null,6,null);
	for (var i=hrefs.snapshotLength - 1;i>=0;--i) {	
		var l = hrefs.snapshotItem(i);
		if (l.textContent.toLowerCase() != stri) {
			//GM_log('OK textContent found: ' + l.textContent + " - stri: "+ stri);
			if (stri != "") {
				YTselectI18n('US', 'gl');
				//GM_log('Worldwide contents ok!');
				break;	
			}
		}  //else GM_log('textContent not found: ' +  l.textContent);
	}
}

// the following function is taken from youtube.com - thanks Firebug
function YTselectI18n(loc, parameter) {
	var current_url, next_url, anchor_url;
	current_url = window.location.href;
	current_url = current_url.split("#");
	anchor_url = current_url.length == 2 ? "#" + current_url[1] : "";
	current_url = current_url[0];
	if (current_url.indexOf("?" + parameter + "=") != -1) {
		var url_array = current_url.split("?" + parameter + "=");
		current_url = url_array[0];
	} else if (current_url.indexOf("&" + parameter + "=") != -1) {
		url_array = current_url.split("&" + parameter + "=");
		current_url = url_array[0];
	}
	if (current_url.indexOf("?persist_" + parameter + "=") != -1) {
		url_array = current_url.split("&persist_" + parameter + "=");
		current_url = url_array[0];
	}
	next_url = current_url + (current_url.indexOf("?") == -1 ? "?" : "&") + parameter + "=" + loc + "&persist_" + parameter + "=1" + anchor_url;
	window.location = next_url;
}

if (document.addEventListener) {window.addEventListener("load", ForceWorldwideContents, false);}
else {window.document.onLoad = ForceWorldwideContents();}