Wikipedia:WikiProject User scripts/Requests/Fulfilled

{{historical}}

This page contains requests for user scripts that have been recently fulfilled. To make a new request, please see Wikipedia:WikiProject User scripts/Requests. For older fulfilled requests, see:

{{TOCright}}

Easy Stubify

Can someone create a script similar to this that adds a stubify tab to the top of articles? Preferably, it would include a pop-up box that asks which stub type, add a summary, then automatically click the preview button at the bottom. Thanks, ~ thesublime514talksign 02:08, July 5, 2007 (UTC)

:Try User:Ais523/stubtagtab.js. --ais523 12:22, 6 July 2007 (UTC)

::Thanks, it works great ~ thesublime514talksign 18:48, July 6, 2007 (UTC)

watch tab that adds images and/or templates of an article to watchlist

class="messagebox small-talk"
Image:Piratey.svg

| style="font-size: small;" | A userscript request is listed on the bounty board

A Wikipedian has pledged to donate $40 (USD) to the Wikimedia Foundation if this request can be filled.

  • Bounty claimed, task fulfilled!

I'd like to request a script that would add a tab (or some other button) that could watchlist all images (and maybe templates) used in an article. A lot of images go unwatched for many articles. It would be great to be able to watchlist all of the images in an article in one click. -- Ned Scott 05:23, 5 February 2008 (UTC)

:I do not work with images, but as far as I know, you will not see deletions or new versions uploads in your watchlist. You will only be notified when someone changes the image description. Also, there doesn't seem to be a way for a script to add a Commons image to your watchlist. Adding templates to your watchlist is possible, however they might include other templates which are still not going to be watched by you ∴ AlexSm 17:30, 5 February 2008 (UTC)

::Yeah, I figured as much. While rare, I have seen some cases of image description page vandalism, and some test edits that have removed image tags and such. Deletion notices would also trigger the watchlist, as well as anything posted on the talk page. Most people probably wouldn't have a use for it, but it's something I've always kind of wanted. -- Ned Scott 07:23, 6 February 2008 (UTC)

:::Another poke, would this even be possible? -- Ned Scott 07:39, 17 February 2008 (UTC)

:Here is something to tide you over until someone writes it for you in nice ajax.

{{hidden|Half of the script|

if(wgNamespaceNumber == 0 && wgAction == 'view' && wgEnableAPI) {

var url = wgServer + wgScriptPath + '/api.php?action=query&prop=images|templates&callback=watchTemplatesImages&format=json&titles=' + encodeURIComponent(wgPageName);

var scriptElem = document.createElement('script');

scriptElem.setAttribute('src',url);

scriptElem.setAttribute('type','text/javascript');

document.getElementsByTagName('head')[0].appendChild(scriptElem);

var imagesHere = new Array();

var templatesHere = new Array();

addOnloadHook(function() {

addPortletLink('p-cactions','javascript:watchTemplatesImagesDo()','Watch All','ca-watchall','Watch all templates and images in this page');

});

}

function watchTemplatesImages(obj) {

if(!obj['query'] || !obj['query']['pages'] || !obj['query']['pages'][wgArticleId]) return

imagesHere = obj['query']['pages'][wgArticleId]['images'];

templatesHere = obj['query']['pages'][wgArticleId]['templates'];

if(!imagesHere) imagesHere = [];

if(!templatesHere) templatesHere = [];

}

function watchTemplatesImagesDo() {

//half-assed watchlist/addendum-generator thing

var cs = document.getElementById('contentSub');

if(!cs) return;

var wall = document.createElement('div');

wall.style.backgroundColor = '#bbffbb';

wall.style.padding = '8px';

wall.appendChild(document.createTextNode('WATCH ALL: Please copy the text in the textarea below to your '));

var wlink = document.createElement('a');

wlink.setAttribute('href',wgServer + wgScript + '?title=Special:Watchlist/raw');

wlink.appendChild(document.createTextNode('Raw watchlist'));

wall.appendChild(wlink);

var wlta = document.createElement('textarea');

wlta.setAttribute('id','wlta');

wlta.setAttribute('readonly','readonly');

wlta.style.height = '6em';

wlta.style.backgroundColor = '#fff6dd';

for(var i=0;i

wlta.value += imagesHere[i].title + '\n';

}

for(var i=0;i

wlta.value += templatesHere[i].title + '\n';

}

wall.appendChild(wlta);

cs.appendChild(wall);

}

}}

:Should work, may be a bit buggy. Creates a textarea in your contentSub that you can copy to your raw watchlist. Someone else can create a queued ajax system that checks to make sure each template exists and each image is local and not on commons. --Splarka (rant) 10:19, 17 February 2008 (UTC)

::Awesome, thanks! -- Ned Scott 06:27, 28 February 2008 (UTC)

:MZMcBride and I had a thought on how you (or rather, whoever writes this) could check the list of images, for if they were local images or not with an intermediary api call. For example if you had :Image:Wiki.png and :Image:Bullet-blue.png as images in a page, an API call like:

/w/api.php?action=parse&format=json&callback=imagecommonscheck&text=:Image:Wiki.png+:Image:Bullet-blue.png

:and then a snippit to check it

function imagecommonscheck(obj) {

var imagecheck = obj['parse'].links;

for(var i=0;i

if(imagecheck[i].exists) {

//this is only true if the image is not on commons, title is: imagecheck[i]['*']

}

}

}

:--Splarka (rant) 07:39, 4 March 2008 (UTC)

::I think a better way to do this is using imageinfo:

/w/api.php?action=query&format=jsonfm&titles=Image:Albert%20Einstein%20Head.jpg|Image:Hitler_with_other_German_soldiers.jpg&prop=imageinfo

To verify:

function imagecommonscheck(obj) {

var imagecheck = obj['query']['pages'];

for(var i=0;i

if(imagecheck[i]['imagerepository'] == "local") {

//this is only true if the image is not on commons, title is: imagecheck[i]['*']

}

}

}

::Not yet tested. Superm401 - Talk 08:35, 23 April 2008 (UTC)

Two new incentives for continued work on this request: one is that MediaWiki has been updated and deletions now show up on the watchlist, and two, I've doubled the bounty on this request from $20 to $40. -- Ned Scott 03:29, 17 April 2008 (UTC)

:And new versions of images too. Also, if it makes it easier, a script that works with just images and not templates would be sufficient for this request. -- Ned Scott 05:53, 18 April 2008 (UTC)

Test this out: User:Splarka/watchimages.js. It is not fully automated though. What it does:

  • On a content page, it adds a toolbox button.
  • If clicked it queries the API for all images.
  • It checks which are local vs commons, which exist, which have description pages.
  • Currently selects local or missing images (with or without pages) not on commons.
  • Sends you to Special:Watchlist/raw with the pages as a URI parameter
  • Appends these to the textarea, alerts you.
  • You then either choose to update, edit, or do nothing.
  • Upon save, it returns you to the page.

Of course, it could be streamlined a bit more. It could be automated, have more logic (check if page has images, check if images are repeats on watchlist, filter out logos, etc). Also, it specifically does not use ajax at this time (ajax POST is annoying), but should be good enough to test. --Splarka (rant) 06:48, 24 April 2008 (UTC)

::Awesome! Even this alone is a huge help, and is probably enough to make claim to the donation bounty. Thanks Splarka! -- Ned Scott 03:32, 25 April 2008 (UTC)

:::A part of the bounty process is to credit those who worked on the task (the bounty hunters). Here's what I have for the donation public comment "en:WP:BOUNTY on image watchlist user script en:user:Splarka/watchimages.js . Major thanks to en:user:Splarka ! Also thanks to en:user: MZMcBride, Superm401, and AlexSm, in discussion."''

:::Obviously Splarka is in there, and since there was room I also included all the names in this thread. Are there any names I should add or remove? -- Ned Scott 03:48, 25 April 2008 (UTC)

::::Well, I went ahead and made the donation, though I was hopping to link to the public comment, I can't seem to figure out how (or where it is displayed). In any case, thank you again for the work on this, and I look forward to seeing how the script develops :D -- Ned Scott 07:53, 26 April 2008 (UTC)

Quickly add a new category

I am requesting a script that would add a link when viewing an article. When clicked on, it will show a JavaScript prompt, requesting for a Category to add to the current article; when one is entered and OK is hit, then the category will be added to the article. Gary King (talk) 07:02, 17 February 2008 (UTC)

:User:ais523/cattab.js is a start at this. It works, but it's a bit rudimentary; it always puts the category at the start of the article's category list (or at the end of the article if it doesn't have a category list), and doesn't handle sortkeys. --ais523 12:59, 25 February 2008 (UTC)

:You may want to try MediaWiki:Gadget-HotCat.js. Superm401 - Talk 01:49, 25 April 2008 (UTC)

=Catgory text string index=

Special:PrefixIndex allows a user to display pages beginning with a particular prefix, such as categories beginning with "Non-article". Is there a way ( would you write me a script) to display pages containing a particular text string, such as categories containing "Non-article". This would allow me to find categories such as :Category:WikiProject Biography non-article pages where "non-article" appears other than at the beginning of the category name. Thanks. GregManninLB (talk) 07:02, 24 April 2008 (UTC)

:Try [http://tools.wikimedia.de/~nikola/grep.php title grep]. That isn't feasable as a userscript. --Splarka (rant) 07:13, 24 April 2008 (UTC)

::Thanks. I followed up here. GregManninLB (talk) 14:04, 24 April 2008 (UTC)

:::User:Nikola Smolenski improved [http://tools.wikimedia.de/~nikola/grep.php wikimedia grep] to search categories with regular text. Thanks again for the lead. GregManninLB (talk) 14:28, 27 April 2008 (UTC)