User:So9q/FilterTranslations.js

From Wiktionary, the free dictionary
Jump to navigation Jump to search

Note – after saving, you may have to bypass your browser’s cache to see the changes.

  • Mozilla / Firefox / Safari: hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (Command-R on a Macintosh);
  • Konqueror and Chrome: click Reload or press F5;
  • Opera: clear the cache in Tools → Preferences;
  • Internet Explorer: hold Ctrl while clicking Refresh, or press Ctrl-F5.

/*
** Filter the list of translations
**
** Author So9q
** Year: 2019
** License: GPL-v3 or later
** Synopsis: Filter the list of translations to hide clutter when translating.
*/
if (typeof window.CustomLanguagesFilter == 'undefined') {
// CustomLanguagesFilter is not defined, set to defaults
window.CustomLanguagesFilter = "[lang=nb], [lang=da], [lang=fr], [lang=de], [lang=sv], [lang=no], [lang=nl]";
}
// Hide all
$(".NavFrame").children(".NavContent")
.find(".translations tr:first-child li").hide();
// Show only the ones we want
$(".NavFrame").children(".NavContent")
.find(".translations tr:first-child li").find(CustomLanguagesFilter).parentsUntil("ul").show();