So, I'm creating a Wikipedia user script, and for it, I need to get the current namespace and get a true
or false
value. I tried using wgCanonicalNamespace
, but this did not work. Here is another script I tried but did not work.
NoRedLinksNamespaces = {
//settings (changed by user on common.js)
};
if(NoRedLinksNamespaces[document.URL.slice("title=", ":")]) {
//code here
}
I want the script to only redirect certain namespaces, (definition I'm going by: "file:" is file, and "talk:" is talk) out of the editor. here is my code.
You get the current namespace number in JavaScript like this:
ns = mw.config.get ('wgNamespaceNumber');