Talk:Snippets/Purge action

Latest comment: 9 months ago by Snævar in topic Vector-2022

Vector support?

edit

I just tried this script out and it didn't seem to work with Vector. It works fine with Monobook. Has this been tested with Vector? Is there some reason it wouldn't work currently? --MZMcBride 03:14, 25 August 2011 (UTC)Reply

How did you try it? When I dump the snippet into the FireBug Console and run it I get a purge link in the p-cactions dropdown menu. Amalthea 07:16, 25 August 2011 (UTC)Reply
I put the code at testwiki:User:MZMcBride/killionboob.js (imported into /monobook.js). I have a "*" tab in Monobook, but in Vector I only see protect/delete/move in the drop-down menu (using a URL like http://test.wikipedia.org/wiki/Easytimelinetest?useskin=vector). Chrome/OS X. --MZMcBride 19:33, 25 August 2011 (UTC)Reply
Imported in /monobook.js, but not in /vector.js. :) Amalthea 20:15, 25 August 2011 (UTC)Reply
Oh, hah. I'm a moron. Thanks. --MZMcBride 22:34, 25 August 2011 (UTC)Reply

Strange loading

edit
$.when(mw.loader.using(['mediawiki.util', 'mediawiki.api', 'mediawiki.notify']), $.ready).then(function ()

Krinkle, forgive my ignorance, but can you break down the above line? What is different between this and simply listing the modules as dependencies in the gadget definition? It implies the code has to wait for the modules to load, but does listing the dependencies (or .using()) not do that by default? -- [[User:Edokter]] {{talk}} 07:44, 19 May 2016 (UTC)Reply

No problem, Edokter! It's like this:
  • $.ready is a promise (usable as $.ready.then(function () { .. }); or via shortcut $(function () { .. });.
  • mw.loader.using() is also a promise. So instead of writing two nested functions like mw.loader.using().then(function () { $(function () { it's nicer to combine the promises via $.when.
Regarding the use of mw.loader in the first place, this is because I want this JavaScript snippet to work even if it is loaded out of context (such as w:MediaWiki:Gadget-UTCLiveClock.js loading MediaWiki:Gadget-UTCLiveClock.js, and many other wikis), and to allow safe copy-and-paste of it anywhere. This is especially common when people use it in a site-wide or user script (which don't have a way to specify dependencies). As always, mw.loader will take not to load things multiple times. It's harmless if they're already loaded as dependencies. --Krinkle (talk) 18:18, 24 May 2016 (UTC)Reply
So the note I added is appropriate, as is the way I have done on enwiki? Just making sure my urge to simplify code is not backfiring. -- [[User:Edokter]] {{talk}} 19:05, 24 May 2016 (UTC)Reply

Advantage to POST and reload?

edit

Recently the purge right has stopped working. Appending ?action=purge to a URL now prompts for confirmation always. The edit to use a POST and then reload appears to have anticipated this behavior. Is there an advantage to POST and reload? Is the change to the behavior of the purge right intentional? --Unready (talk) 00:03, 22 August 2016 (UTC)Reply

For reference, en:Wikipedia:Village pump (technical)#Purge links require confirmation step. --Unready (talk) 00:06, 22 August 2016 (UTC)Reply
See also phab:T136375. Xaosflux (talk) 00:48, 22 August 2016 (UTC)Reply
phab:T143531 is probably the better reference. --Unready (talk) 20:27, 22 August 2016 (UTC)Reply

Vector-2022

edit

This snippet should support vector 2022, something like is:Special:Diff/1845680 should work, but I suppose that can be improved upon. Snævar (talk) 15:13, 23 January 2024 (UTC)Reply

Return to "Snippets/Purge action" page.