19
submitted 4 days ago by Erika3sis@hexbear.net to c/main@hexbear.net

I spend a lot of time reading Wikipedia. Most often because I'm suddenly curious about something, type @wikien (my own shortcut for English Wikipedia) into Firefox's address bar, hit the down arrow key, and then type the name of the thing in question in English. I also have shortcuts for @wikija (Japanese Wikipedia), @wikieo (Esperanto Wikipedia), @wikino (Norwegian Bokmål Wikipedia) and @wikiru (Russian Wikipedia), but I use these shortcuts way less often than @wikien despite wanting to increase the proportion of non-English reading I do online.

Even if I don't use these shortcuts I've set up, it is of course always possible to click on the language dropdown and select a different language if I really want to read a specific Wikipedia article in a specific language, but this adds "friction" don't people say, so I always end up just reading what I was curious about on English Wikipedia and then closing the tab. So wouldn't it be nice if I could look something up on English Wikipedia and have it automatically redirect to the equivalent article on Norwegian Wikipedia? I think that would be nice, but evidently nobody has ever made such a browser extension despite how easy it seems like it would be. Wikipedia's API has a feature for finding equivalent articles between different languages, right? Surely you could use that for this sort of project, right?

I imagine the Wikipedia Language Redirector browser extension working like this for the end user: you click on the Wikipedia Language Redirector icon in the corner of your web browser, and it opens a popup with (1) a simple button for enabling or disabling the redirector; (2) a searchable list of different editions of Wikipedia, sorted from most to least articles, with names in their respective languages.

Every entry in this list of Wikipedias has two buttons: a pin icon and a prohibition icon. These buttons are for respectively pinning and denylisting that version of Wikipedia. Pinned Wikipedias are marked in blue and moved to the top of the list, and can be dragged up and down relative to each other to prioritize them. Denylisted Wikipedias are marked in red and also moved to the top of the list, just beneath the pinned Wikipedias. The prohibition icon on denylisted Wikipedias is replaced with a checkmark icon for moving that Wikipedia back to the allowlist.

So for myself, I might set English Wikipedia (en.wikipedia.org / 7,135,897 articles) as denylisted, and then pin these Wikipedias in this order:

  1. Norwegian Bokmål (no.wikipedia.org / 672,884 articles)
  2. Norwegian Nynorsk (nn.wikipedia.org / 177,247 articles)
  3. Danish (da.wikipedia.org / 312,694 articles)
  4. Swedish (sv.wikipedia.org / 2,621,329 articles)
  5. Esperanto (eo.wikipedia.org / 381,760 articles)
  6. Toki Pona (tok.wikipedia.org / 3,570 articles)
  7. Russian (ru.wikipedia.org / 2,085,436 articles)
  8. Japanese (ja.wikipedia.org / 1,489,743 articles)
  9. Chinese (zh.wikipedia.org / 1,523,539 articles)

The behavior of the Wikipedia Language Redirector browser extension is then that when it notices I'm on denylisted English Wikipedia, it will first check if there's an equivalent article on Norwegian Bokmål Wikipedia; then if there isn't, it will check Norwegian Nynorsk Wikipedia; then Danish, Swedish, etc, in my chosen order, and if none of my pinned languages have an equivalent to the article I'm looking for, Wikipedia Language Redirector will just give up and load the English Wikipedia article anyways.

If I'm looking at an allowlisted but not necessarily pinned edition of Wikipedia, the extension just does nothing.

you are viewing a single comment's thread
view the rest of the comments
[-] Enjoyer_of_Games@hexbear.net 4 points 4 days ago

You can install the Firemonkey extension.

and use it to run this script

// ==UserScript==
// @name         Erika3sis
// @version      2026-02-12
// @match        https://*.wikipedia.org/*
// @description  Redirects wikipedia pages to alternate language pages in order of predefined preference
// @author       Enjoyer_of_Games
// @run-at       document-idle
// @license      AGPL 3+
// ==/UserScript==

console.log(window.location);

function switchtoLanguage(langCode) {
    const checkbox = document.getElementById('p-lang-btn-checkbox');
    if (checkbox && !checkbox.checked) {
        checkbox.click(); // Open the dropdown
        console.log('Checkbox clicked to open dropdown');
    }
    let linktarget = document.querySelector(`a.interlanguage-link-target[lang="${langCode}"]`);
    if(linktarget){
        let langLink = linktarget.href;
        if (langLink){
          console.log(`Navigating to language: ${langCode}`);
          window.location.href = langLink;
          return true;
        }
        else {
           console.warn(`Could not find language link for "${langCode}"`);
        }
    }
}

const langBtn = document.querySelector('#p-lang-btn');

let result = false;
do{
    if (langBtn) {
        let LanguageList = ['no', 'nn', 'da', 'sv', 'eo', 'tok', 'ru', 'ja', 'zh'];
        for (const langCode of LanguageList) {
            let result = switchtoLanguage(langCode);
            if (result){
                console.log('finished');
                break;
            }
        }
    }
    else {
        console.log('Could not find the #p-lang-btn element');
    }
}
while(result !== true);
[-] edie@lemmy.encryptionin.space 4 points 4 days ago* (last edited 4 days ago)

You must include https:// in links


This user is suspected of being a cat. Please report any suspicious behavior.

[-] Enjoyer_of_Games@hexbear.net 1 points 4 days ago
[-] edie@lemmy.encryptionin.space 1 points 4 days ago

https://lemmy.encryptionin.space/post/addons.mozilla.org/en-CA/firefox/addon/firemonkey/

It doesn't on mine.


This user is suspected of being a cat. Please report any suspicious behavior.

[-] Erika3sis@hexbear.net 3 points 4 days ago* (last edited 4 days ago)

Doesn't seem to work quite as it's supposed to, but this is a really great start and I'm really glad you'd throw this together for me in a pinch.

Unexpected behavior (note: I'm running the script through TamperMonkey rather than FireMonkey):

  1. Upon loading an article, the script redirects me to that article in Nynorsk rather than Bokmål, despite Bokmål being the first language in the priority list. In essence, it's like the script skips the first language in the list for some reason.
  2. Redirects occur regardless of language, when they're only supposed to happen when I attempt to access an article on English Wikipedia.
  3. Every subsequent page I click on after the initial redirect, redirects me to the equivalent page in the next language in the list: so if I click on the main page from Nynorsk Wikipedia, it loads the Danish Wikipedia's main page; if I click on one of the articles from the Danish Wikipedia's main page, it loads the article I clicked on in Swedish, et cetera.

Edit: Thanks Edie for fixing issues 2 and 3

[-] Enjoyer_of_Games@hexbear.net 3 points 4 days ago

Those are all features ... to uh help you avoid wiki rabbit holes yeah that's it.

[-] edie@lemmy.encryptionin.space 2 points 4 days ago* (last edited 4 days ago)

2 (and to some extent 3) can be fixed by replacing

// @match        https://*.wikipedia.org/*

with

// @match        https://en.wikipedia.org/*

This user is suspected of being a cat. Please report any suspicious behavior.

[-] Erika3sis@hexbear.net 2 points 4 days ago* (last edited 4 days ago)

That worked, awesome! Should've probably figured that out myself, but at least it was a simple enough issue to solve.

[-] edie@lemmy.encryptionin.space 2 points 4 days ago

Also I think you can remove

    const checkbox = document.getElementById('p-lang-btn-checkbox');
    if (checkbox && !checkbox.checked) {
        checkbox.click(); // Open the dropdown
        console.log('Checkbox clicked to open dropdown');
    }

it doesn't actually seem to make a difference.


This user is suspected of being a cat. Please report any suspicious behavior.

[-] Erika3sis@hexbear.net 2 points 4 days ago

I don't notice any difference, either.

[-] edie@lemmy.encryptionin.space 2 points 4 days ago* (last edited 4 days ago)

Here is my modified version which seems to work better. The original one would continuously attempt to navigate to a page, resulting in firefox creating an error, whereas mine doesn't. I have removed the unnecessary open checkbox. And I have fixed norsk bokmål being nb not no

script

// ==UserScript==
// @name         Erika3sis
// @version      2026-02-12
// @match        https://en.wikipedia.org/*
// @description  Redirects wikipedia pages to alternate language pages in order of predefined preference
// @author       Enjoyer_of_Games
// @author       Edie
// @run-at       document-idle
// @license      AGPL 3+
// ==/UserScript==

const langBtn = document.querySelector('#p-lang-btn');

let result = false;
do{
    if (langBtn) {
        let LanguageList = ['nb', 'nn', 'da', 'sv', 'eo', 'tok', 'ru', 'ja', 'zh'];
        for (const langCode of LanguageList) {
            let linktarget = document.querySelector(`a.interlanguage-link-target[lang="${langCode}"]`);
            if(linktarget){
                let langLink = linktarget.href;
                if (langLink){
                  console.log(window.location);
                  console.log(`Navigating to language: ${langCode}`);
                  result = true;
                  window.location.href = langLink;
                  break;
                }
                else {
                   console.warn(`Could not find language link for "${langCode}"`);
                }
            }
        }
    }
    else {
        console.log('Could not find the #p-lang-btn element');
    }
}
while(result !== true);


This user is suspected of being a cat. Please report any suspicious behavior.

[-] Erika3sis@hexbear.net 2 points 4 days ago

Seems to work perfectly, and a lot faster! Thank you for your service, and @Enjoyer_of_Games@hexbear.net for the original version of the script.

[-] edie@lemmy.encryptionin.space 2 points 4 days ago

Also, it seems it is unnecessary to open the checkbox? And I get this warning: "Too many calls to Location or History APIs within a short timeframe." which makes sense, there is no check in the code to not attempt to navigate to a page once we have done so. It works, but there are problems.


This user is suspected of being a cat. Please report any suspicious behavior.

this post was submitted on 12 Feb 2026
19 points (100.0% liked)

Main, home of the dope ass bear.

16111 readers
68 users here now

THE MAIN RULE: ALL TEXT POSTS MUST CONTAIN "MAIN" OR BE ENTIRELY IMAGES (INLINE OR EMOJI)

(Temporary moratorium on main rule to encourage more posting on main. We reserve the right to arbitrarily enforce it whenever we wish and the right to strike this line and enforce mainposting with zero notification to the users because its funny)

A hexbear.net commainity. Main sure to subscribe to other communities as well. Your feed will become the Lion's Main!

Good comrades mainly sort posts by hot and comments by new!


gun-unity State-by-state guide on maintaining firearm ownership

guaido Domain guide on mutual aid and foodbank resources

smoker-on-the-balcony Tips for looking at financials of non-profits (How to donate amainly)

frothingfash Community-sourced megapost on the main media sources to radicalize libs and chuds with

just-a-theory An Amainzing Organizing Story

feminism Main Source for Feminism for Babies

data-revolutionary Maintaining OpSec / Data Spring Cleaning guide


ussr-cry Remain up to date on what time is it in Moscow

founded 5 years ago
MODERATORS