Last active
November 23, 2016 10:32
-
-
Save Shaked/bfc145808a639f85a02dfe03cd03cf60 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==UserScript== | |
| // @name Wikipedia English Translation | |
| // @namespace https://wikipedia.org/* | |
| // @version 0.0.4 | |
| // @downloadURL https://gist.github.com/raw/bfc145808a639f85a02dfe03cd03cf60/WikipediaEnglishTranslation.user.js | |
| // @updateURL https://gist.github.com/raw/bfc145808a639f85a02dfe03cd03cf60/WikipediaEnglishTranslation.meta.js | |
| // @description Add the English term to the current term's title. | |
| // @include https://*wikipedia.org/* | |
| // @match https://*wikipedia.org/* | |
| // @grant GM_setValue | |
| // @grant GM_getValue | |
| // @require http://code.jquery.com/jquery-2.1.4.min.js | |
| // ==/UserScript== |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==UserScript== | |
| // @name Wikipedia English Translation | |
| // @namespace https://wikipedia.org/* | |
| // @version 0.0.4 | |
| // @downloadURL https://gist.github.com/raw/bfc145808a639f85a02dfe03cd03cf60/WikipediaEnglishTranslation.user.js | |
| // @updateURL https://gist.github.com/raw/bfc145808a639f85a02dfe03cd03cf60/WikipediaEnglishTranslation.meta.js | |
| // @description Add the English term to the current term's title. | |
| // @include https://*wikipedia.org/* | |
| // @match https://*wikipedia.org/* | |
| // @grant GM_setValue | |
| // @grant GM_getValue | |
| // @require http://code.jquery.com/jquery-2.1.4.min.js | |
| // ==/UserScript== | |
| function getLang(subDomain){ | |
| if (subDomain == 'he') { | |
| return ['en']; | |
| } | |
| if (subDomain != 'en'){ | |
| return ['en','he']; | |
| } | |
| return ['he']; | |
| } | |
| var subDomain = document.location.href.substring(8,10); | |
| console.log("subDomain", subDomain); | |
| function getExtraTitle(lang) { | |
| var link = $('.interwiki-'+ lang +' a')[0].getAttribute('href'); | |
| var translatedFromEnglish = link.substring(link.lastIndexOf('/')+1) | |
| if (lang == "he") { | |
| translatedFromEnglish = decodeURIComponent(translatedFromEnglish); | |
| } | |
| translatedFromEnglish = translatedFromEnglish.replace(/_/g, " "); | |
| return "<div class='wikipedia-english-translation-class'><a href='"+link+"'>"+translatedFromEnglish+"</a></div>"; | |
| } | |
| var langs = getLang(subDomain); | |
| for (var i in langs) { | |
| var lang = langs[i]; | |
| $("#firstHeading").append(getExtraTitle(lang)); | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
0.0.3 supports multi languages: