Mam problem z grą Die Siedler Online, na początku gra pojawiła się tylko na sserwerach w języku niemieckim i tam zacząłem grać. Po ok. roku pojawiła się wersja polska i tedy dało mi się znaleść skrypt na userscript, który spolszcza interfejs. Nie chciałem marnować roku grania i zostałem na serwerze niemiecki, ratując się spolszczeniem. Dziś skrypt przestał działać.
Oryginalny skrypt dający angielski język : http://userscripts.org/scripts/show/93510
Przerobiony skrypt dający język polski: http://userscripts.org/scripts/show/102221
Wiem że chodzi o element flashvars
To kod skryptu, którego korzystałem do dzisiaj
// ==UserScript== // @name The Settlers Online Test Server Language Change // @description Plik został zrobiony na podstawie Die Siedler Online Language Change by Drogas // @version 1.1.1 // ==/UserScript== var embed = document.getElementById("SWMMO"); var vars = []; var getsetSupport = false; //Chrome does not support GM_* commands, sad =\ if (typeof GM_getValue=='function') { GM_setValue("test",true); getsetSupport=GM_getValue("test"); } for (var i=0;i<embed.attributes.length;i++) vars[embed.attributes[i].name.toLowerCase()]=embed.attributes[i].value; function setLanguage(language) { if (getsetSupport) { alert("Wybierz język \r\nz: "+GM_getValue("lang")+"\r\nna: "+language+"\r\nZmiana nastąpi po odświeżeniu strony."); GM_setValue("lang", language); } switchLang(); } function setCountry(country) { if (getsetSupport) { alert("Wybierz kraj \r\nz: "+GM_getValue("country")+"\r\nna: "+country+"\r\nZmiana nastąpi po odświeżeniu strony."); GM_setValue("country", country); } } function switchLang() { document.body.innerHTML = ""; var newembed = document.createElement("embed"); for (var i in vars) { newembed.setAttribute(i, vars[i]); } var val=vars["flashvars"]; if (getsetSupport)val=val.replace(/lang=[a-z]{2}-[a-z]{2}/gi,"lang="+GM_getValue("lang")); else val=val.replace(/lang=[a-z]{2}-[a-z]{2}/gi,"lang=pl-pl"); if (getsetSupport)val=val.replace(/country=[a-z]{2}/gi,"country="+GM_getValue("country")); newembed.setAttribute("flashvars", val); document.body.appendChild(newembed); } if(getsetSupport) { GM_registerMenuCommand("Zmień język na Niemiecki", function(){setLanguage("de-de");}); GM_registerMenuCommand("Zmień język na Angielski", function(){setLanguage("en-us");}); GM_registerMenuCommand("Zmień język na Polski", function(){setLanguage("pl-pl");}); GM_registerMenuCommand("Ustaw kraj na Niemiecki", function(){setCountry("DE");}); GM_registerMenuCommand("Ustaw kraj na Angielski", function(){setCountry("EN");}); GM_registerMenuCommand("Ustaw kraj na Polski", function(){setCountry("PL");}); GM_registerMenuCommand("Pokaż ustawienia", function(){alert("Bieżący język: "+GM_getValue("lang")+"\r\nBieżący kraj: "+GM_getValue("country"));}); if (!GM_getValue("lang")) { setLanguage("pl-pl"); } if (!GM_getValue("country")) { GM_setValue("country", /country=([a-z]{2})/gi.exec(vars["flashvars"])[1]); } } switchLang();
Inspektor DOM i stylów pokazuje mi taki kod:
<html slick-uniqueid="1"> <body scroll="no"> <embed id="SWMMO" width="100%" height="100%" align="middle" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer" allowfullscreeninteractive="true" allowfullscreen="true" allowscriptaccess="always" name="SWMMO" bgcolor="#869ca7" quality="high" flashvars="lang=&e=true&ubb=true&bb=http://w03bb01.diesiedleronline.de/&s=http://static14.cdn.ubi.com/settlers_online/live/SWMMO|http://static13.cdn.ubi.com/settlers_online/live/SWMMO&chatS=http://89.234.31.191:80&chatB=http://89.234.31.191:80&country=PL&realmBeta=false&realmLang=de" src="http://static14.cdn.ubi.com/settlers_online/live/SWMMO/debug/aa2d540e8477327cebea764eaf77d3c98a801721.swf"> </embed> </body> </html>
A to kawałek kodu, który widzę jak włączę pokaż źródło strony;
<script language="JavaScript" type="text/javascript"> var hasProductInstall = DetectFlashVer(6, 0, 65); var hasRequestedVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision); if ( hasProductInstall && !hasRequestedVersion ) { var MMPlayerType = (isIE == true) ? "ActiveX" : "PlugIn"; var MMredirectURL = window.location; document.title = document.title.slice(0, 47) + ' - Flash Player Installation'; var MMdoctitle = document.title; var alternateContent = 'Um Die Siedler Online spielen zu können brauchen Sie die aktuelle Version des Adobe Flash Players.<br>Leider konnten wie keine aktuelle Version erkennen. Bitte aktualisieren Sie Ihre Flash Player Installation unter: <a href=http://www.adobe.com/go/getflash/>http://www.adobe.com/go/getflash/</a>'; document.write(alternateContent); // insert non-flash content } else if (hasRequestedVersion) { AC_FL_RunContent( "src", "http://static14.cdn.ubi.com/settlers_online/live/SWMMO/debug/aa2d540e8477327cebea764eaf77d3c98a801721", "flashVars", "lang=&e=true&ubb=true&bb=http://w03bb01.diesiedleronline.de/&s=http://static14.cdn.ubi.com/settlers_online/live/SWMMO|http://static13.cdn.ubi.com/settlers_online/live/SWMMO&chatS=http://89.234.31.191:80&chatB=http://89.234.31.191:80&country=PL&realmBeta=false&realmLang=de", "width", "100%", "height", "100%", "align", "middle", "id", "SWMMO", "quality", "high", "bgcolor", "#869ca7", "name", "SWMMO", "allowScriptAccess","always", "allowFullScreen", "true", "allowFullScreenInteractive", "true", "type", "application/x-shockwave-flash", "pluginspage", "http://www.adobe.com/go/getflashplayer" ); } else { // flash is too old or we can't detect the plugin var alternateContent = 'Um Die Siedler Online spielen zu können brauchen Sie die aktuelle Version des Adobe Flash Players.<br>Leider konnten wie keine aktuelle Version erkennen. Bitte aktualisieren Sie Ihre Flash Player Installation unter: <a href=http://www.adobe.com/go/getflash/>http://www.adobe.com/go/getflash/</a>'; document.write(alternateContent); // insert non-flash content }
Liczę na dobre rady, bo z programowania jestem noga.
Z góry dzięki