Extension talk:GlobalCssJs

About this board

Import local script globally

6
Can I Log In (talkcontribs)

I've noticed that you can apparently import a local script and make it global. How do you do that?

Pppery (talkcontribs)

You can pass the raw URL of the script to mw.loader.load in your global JavaScript. For example, I load in m:User:Pppery/global.js using mw.loader.load("https://en.wikipedia.org/w/index.php?action=raw&title=User:Pppery/no-ooui-contribs.js&ctype=text/javascript").

This post was hidden by Pppery (history)
Can I Log In (talkcontribs)

So what I'm seeing here is that you need the "&action=raw" and "&ctype=text/javascript". Is this how it's done?

Pppery (talkcontribs)

Well, that's how I do it at least, and it works for me. If you want a more detailed explanation, you should probably ask at Project:Support desk or w:Wikipedia:Village pump (technical), since this talk page is fairly low traffic and I only noticed your post via recent changes patrol.

Quiddity (talkcontribs)
Reply to "Import local script globally"
KaiKemmann (talkcontribs)

Quote from the article:

"Functions like <code>importScript</code> will not work as those use the local wiki, not the global one."

I cannot seem to figure out the meaning of this sentence.

Can someone help?

best regards,

--~~~~

PerfektesChaos (talkcontribs)

First, you are talking in the wrong thread, or for the wrong page, since the quotation is occurring on Help:Extension:GlobalCssJs.

Second, the grammar is not pretty indeed, could be read as "nor the global one", but actually means: An importScript() call will refer to the local wiki currently in use, not to a page with this name on Meta wiki, which is usually not intended.

Third, it says that using global resources, you are encouraged to use full URL including project domain, if it shall be shared among all wikis, since importScript() calls are related to pages on current local wiki.

Quiddity (WMF) (talkcontribs)
Reply to "Strange wording"

Per-skin customization works

1
71.36.99.196 (talkcontribs)
Reply to "Per-skin customization works"

Ability to exclude a wiki?

6
Billinghurst (talkcontribs)

@Legoktm: Is there an ability to exclude wikis? For instance, I wish to exclude English Wikisource from my global rollout, as I use other tools there and addition of global.js causes issues. I thought that the script configuration looked to sectionalise what was rolled where, however, I see that the output of onEveryWiki() is additive. Thanks.

Legoktm (talkcontribs)

You can wrap your global.js in:

if ( mw.config.get("wgDBname") !== "enwikisource" ) {
	// Whatever JavaScript you want to run on all wikis but enwikisource
}
XXN (talkcontribs)

hmm, for me this doesn't work...

Legoktm (talkcontribs)

Can you expand on how it's not working?

XXN (talkcontribs)

@Legoktm: Please take a look at my global.js; I tried to disable my personal popups.js on Wikidata and edittop.js on ruwiki and enwiki, but both these scripts continue to be loaded everytime on the specified wikis.

XXN (talkcontribs)

Ah, found, fixed, works. If for wikisource it's necessary to specify long DB name (i.e.: "enwikisource"), for wikipedias it's necessary to specify short DB name (for example "enwiki").

Reply to "Ability to exclude a wiki?"

Home wiki

4
Summary by SamB

Q: Why not put global css/js on the user's home wiki?

A: Which wiki is considered a user's "home" wiki is essentially random, cannot be changed by the user, and could be someplace with much laxer requirements for becoming an administrator than meta.wikimedia.org, like test.wikipedia.org.

Edokter (talkcontribs)

Would it not make a lot more sense to load a users' global scripts from its home wiki, as designated in Special:CentralAuth? I am rarely on meta, so requiring users to store their global code there seems overly complicated.

Jack Phoenix (talkcontribs)

Nope. Or at least this is something I wouldn't be able to see as an improvement until CentralAuth has a way to set your home wiki. MediaWiki.org is my home wiki in terms of edits and user rights and overall activity, but CA thinks my home wiki is test.wikipedia.org, where I have a whopping nine (!) edits and some user rights. So no, I wouldn't want to have my global CSS & JS stored on test.wikipedia.org; Meta in the context of WMF wikis makes total sense to me as it's a central place for coordination.

Legoktm (talkcontribs)

Yes, what Jack said. CentralAuth has some unreliable criteria with which it picks a home wiki, and it's really only used to figure out who wins the account. Also, from a security perspective it is much safer to only allow meta admins to edit your global scripts, as opposed to any testwiki admin :/.

Reply to "Home wiki"

Automated deletions by User:Maintenance script

4
MarcoAurelio (talkcontribs)

Hi. At es.wikibooks I've noticed the following:

04:42 7 sep 2014 Maintenance script (discusión | bloquear) borró Usuario:Makecat/common.js (Deleting JavaScript page on user request due to deployment of mw:Help:Extension:GlobalCssJs) (ver/restaurar)

I wonder if those who have dozens of crosswiki .css/.js pages such as me can also "order" that script to perform the cleanup or is just reserved for users with higher levels of access in the DB. If possible, how is it done? - I have translated some system messages regarding this on betawiki, but I can't figure out how to run that cleanup.

Best regards.

Legoktm (talkcontribs)

That was a script that was run server-side by Krinkle and myself during the initial migration. I'd recommend you file a request with m:Synchbot and Pathoschild can delete them for you.

MarcoAurelio (talkcontribs)

Thanks for you reply. Isn't the script working anymore then? I filed both a request on Meta for your script and Pathoschild's one. Best regards.

Legoktm (talkcontribs)

It probably still works but had issues with being blocked by the AbuseFilter, and was generally less flexible than Pathoschild's script was, which is why I've been letting him take care of it.

Reply to "Automated deletions by User:Maintenance script"

Add a link to special pages of local wikis

5
Superchilum (talkcontribs)

@Legoktm: Is there a possibility to add a link to special pages, which changes for every wiki? With local js I used to link to "https://it.wikivoyage.org/wiki/Special:UnconnectedPages", "https://it.wikiquote.org/wiki/Special:UnconnectedPages" etc. How can I do now with global js? Does it exist something like "http://LOCALWIKI/wiki/Special:UnconnectedPages", so if I'm on it.quote it will link to https://it.wikiquote.org/wiki/Special:UnconnectedPages, if I'm on en.voy it will link to https://en.wikivoyage.org/wiki/Special:UnconnectedPages etc.?

Legoktm (talkcontribs)

You can use:

var url = "https:" + mw.config.get('wgServer') + "/wiki/Special:UnconnectedPages";

And use the url variable wherever you need it.

Superchilum (talkcontribs)

@Legoktm: Thanks :-) I've modified accordingly, but no link appears... why?

Ricordisamoa (talkcontribs)

mw.util.getUrl returns a relative URL, but it should suffice for your purposes.

Example:

mw.util.getUrl('Special:UnconnectedPages')

Using my superpower, I guessed that you enabled the "collegamenti personali" gadget on the Italian Wikipedia. Unfortunately, it doesn't work on Meta-Wiki, but you can still use the standard mw.util.addPortletLink function:

mw.util.addPortletLink( 'p-navigation', mw.util.getUrl('Special:UnconnectedPages'), 'Pagine non connesse', 'unconnected-pages' );
Superchilum (talkcontribs)

@Ricordisamoa: Thank you so much, it does work! Regarding the "collegamenti personali" gadget, do you mean I can delete the line from my global.js?

Reply to "Add a link to special pages of local wikis"
There are no older topics
Return to "GlobalCssJs" page.