Wikipedia talk:WikiProject User scripts/Scripts

From Wikipedia, the free encyclopedia

Contents

[edit] Script explanations

It is unclear what exactly many of these scripts do without trial and error or javascript fluency. Could someone who knows perhaps add a word or two of explanation / documentation? Much appreciated. here 05:53, 6 November 2005 (UTC)

Thank you! here 18:04, 6 November 2005 (UTC)

[edit] Firefox fix for "since" tab

I have fixed the "since" script for Firefox 1.5 RC1; see my monobook.js for the code. It involves an additional helper function, but it's a very handy helper to have anyway. YMMV, but do let me know if you have any trouble with my version. Much thanks to the original authors! HorsePunchKid 08:18, 11 November 2005 (UTC)

[edit] AutoAfd

I'm having trouble with the Auto AFD script Wikipedia:WikiProject_User_scripts/Scripts/AutoAFD.js listed here. I've added it to my User:Here/monobook.js, before godmode-light.js and nav-tabs at bottom of page. no dice. does it perhaps need the add tab or add li link modules? here 07:18, 15 November 2005 (UTC)

Did you refresh your browser cache? It may be that you're not looking in the right place: one difference between Auto AFD and afd helper is that the latter puts a 'Nominate AFD' button in the toolbox when viewing a page; the former puts a tab up the top of the page when you are editing the page. This is now being clarified in the scripts table. jnothman talk 08:12, 15 November 2005 (UTC)
Thanks, wasn't editing the page to look for the afd tab. here 08:20, 15 November 2005 (UTC)

[edit] Replace script

Is anyone using the Wikipedia:WikiProject User scripts/Scripts/Replace script? It seems very useful and i would like to make it work. If there is any example it would be much appreciated, thx

I use a regex replace tab from User:Trilobite/ToolsOmegatron 02:48, 12 January 2006 (UTC)

[edit] Test-n

The test-n.js script doesn't seem to be working for me. I put it in monobook.js, hit Ctrl-F5, then tried to edit a user talk page. I could find no automated way to add templates anywhere on the page.

The only other scripts I have installed are Lupin's popups and filter recent changes scripts. Am I doing something wrong? —Simetrical (talk) 05:32, 15 December 2005 (UTC)

No, it's not your fault. Nor is it Lupin's. The script didn't have anything that actually loaded it / made it run. I've changed the script and it now has a dependency, or you could do anything equivalent yourself to make the add_tabs function run on page-load. jnothman talk 05:42, 15 December 2005 (UTC)

[edit] Taking advantage of existing Wikipedia js code

There are a lot of useful functions in the standard wikibits.js and site.js files. Not only do these functions come "free" with every Wikipedia page, but they can generally be expected to be better tested and more portable that anything we can cobble together. I feel we should therefore strive to make as much use of them as possible.

For example, both of these files include a function for adding onload hooks, something that most user scripts require. Currently each one seems to be doing this in a slightly different way — all of which probably work just fine, but the redundancy is needless and sometimes confusing. I'd recommend replacing all of them with addOnloadHook(myFunction). This even works with anonymous functions, reducing the risk of bugs caused by namespace conflicts. —Ilmari Karonen (talk) 17:34, 17 December 2005 (UTC)

I have changed those scripts listed here to use wikibits.js's addOnloadHook. Thanks for suggesting so. jnothman talk 22:13, 18 December 2005 (UTC)

[edit] Test-n script

I've done some crude modification to this script on User:Johnleemk/monobook.js by making a t5 tab for admins who want to use the test5-n template. Comments welcome. Johnleemk | Talk 09:52, 14 January 2006 (UTC)

[edit] Auto AFD

I had a problem with it. I used it to put up an afd and entered my info into the box, hit enter and it bypassed the second step and left the entry page with a red link. I manually finished the afd and the link still stayed red. The entry was present at the articles for deletion but the entry page was empty. Sought help but no one was in. Finally fixed it by clearing my browser. Am wondering if it could be a bug with Opera which I was using.--Dakota ~ ε 05:15, 23 January 2006 (UTC)

It may have been a bug related to characters in the particular article name... What article was it? You can try the alternative, afd helper which also makes it easier to vote on AFDs... And I use it in Opera. jnothman talk 08:44, 23 January 2006 (UTC)
It was the article GAJ which is as it should be now. I use both the afd helper and auto afd which are great tools BTW. I think it was clearing the cache that fixed it for some reason. I use both Opera and Firefox never IE. I am relatively new to Opera and was wondering if it has problems with monobook.js scripts but think the question is now answered if you use with no problems. Thank you.--Dakota ~ ε 19:07, 23 January 2006 (UTC)

[edit] Help with my monobook.js

See my post here! I would appreciate the assistance of anyone who can help! J@redtalk+ ubx  03:02, 26 March 2006 (UTC)

[edit] Vandal warning toolbox

I've written some tools for warning vandals for my own use that others are finding quite useful, too. I wonder if there is a home for it under this project? --Kbh3rdtalk 16:19, 11 April 2006 (UTC)

Very cool! I took the liberty of updating a link on that page to help direct users to their monobook.js file; hope you don't mind. B.Rossow talkcontr 17:57, Tuesday [[April 11]] [[2006]] (UTC)

[edit] CSD template menu

Another script for anyone to comment on and suggest improvements. User:Jwestbrook/Template Menu

J\/\/estbrook Talk VSCA  20:12, 27 April 2006 (UTC)

[edit] Autocopyvio.js

I am totally illiterate when it comes to scripts, but does the Autocopyvio.js script work? Either it doesn't or I fail to understand what to do with it. But just by looking at the page, it doesn't look like the other scripts. Is it just that I don't get it? Thanks. IronChris | (talk) 04:55, 14 May 2006 (UTC)

[edit] A question...

I'd installed a (series of) code(s) on my monobook.js that allowed me to;

Have access to Lupin's Anti Vandal Showed me the clock next to log out Navigation Popups Last Change Edit Counts

Now, as I was experimenting with my monobook I screwed up and lost my old code. I've installed AV, Navigation popups, edit count once again, I really don't mind the loss of clock but I really would like to have Last Change.

Now, as far as I remember I didn't have neither addLink, addLiLink, or Add tab before -it was a simple code. Now I've tried to install addLink, tab and then Last change code, and it didn't work. I think I'm screwing something up...

a) Should I install both addLink AND AddLiLink before AddTab? b) What code should I *exactly* copy/paste? I've tried copy pasting the codes shown in pages, codes via Edit Page and neither seemed to work.

Any-all helps would be appreciated. Kedi the tramp (talkcontribscount) (Respond to me on my Talk.) 15:44, 12 July 2006 (UTC)

Alright, I've handled all. I guess I should have a copy on a text file. ;D Kedi the tramp (talkcontribscount) (Respond to me on my Talk.) 16:02, 12 July 2006 (UTC)

[edit] Help please

function rrresp(result)
{
    var txt = document.editform.wpTextbox1;
    txt.value = txt.value.replace("(Result:)", "(Result: "+result+")");
    txt = document.editform.wpSummary;
    txt.value = txt.value + result;
document.editform.submit();
}

This completely breaks. Why? Will (Take me down to the Paradise City) 21:52, 2 August 2006 (UTC)

What happens? You need to give details. --LorianTC 06:40, 3 August 2006 (UTC)
Everything in my monobook stops working (popups, functions, custom links, everything). It's supposed to semi-automate WP:AN3 Will (Take me down to the Paradise City) 09:42, 3 August 2006 (UTC)
Try commenting out lines working backwards to see where the problem is. --LorianTC 10:28, 3 August 2006 (UTC)

[edit] Helper functions

"Remember to put the helper functions before the code that requires them."

Wouldn't it be easier to recommend a sort of lightweight framework that makes this unnecessary? I know that several javascript "easyfier"-frameworks contain stuff like that, and it can't be all that hard.

You could use a predefined array to hold the names of all scripts already loaded. Scripts loaded could add themselves to the list. You would probably still want to put these helpers in a seperate script, but at least it's only one script, and you could define a parameter to let it load other scripts. The result could greatly improve usability of user scripts.

An example will clarify.

Suppose you could say in your user script:

ScriptsToLoad = {"script1", "script2"};
document.write('<script src="frameworkthingy.js"><\/script>');

Then it would initialize an array, say LoadedScripts, to {} and call a LoadScript function for every item in ScriptsToLoad. The function itself could be relatively simple, something like:

v = LoadedScripts[scriptname];
if(v) callback(v);
LoadScriptCallbacks[scriptname] = callback;
document.write('<script src="' + scriptname + '.js"><\/script>');

Note that the use of callbacks is not really preventable, since you have to make sure that code dependent on a library is not executed before it's loaded. The script to load would call another function, say ScriptLoaded, when it's ready to be used. It could go something like this:

LoadedScripts[scriptname] = someobject;
LoadScriptCallbacks[scriptname](someobject);

This would make reusing functionality much easier. I'm even willing to write the thing, at least if I'm not the only one who thinks this idea makes sense. Shinobu 12:37, 3 August 2006 (UTC)

[edit] Improve Overview

Could the intro to the Scripts page be improved? Starting out with "there are a bunch of user scripts" is not terribly helpful. Is there some place that describes, for the beginner, what User scripts do generally, how they are added. etc.? --Rschmertz 17:38, 1 October 2006 (UTC)

[edit] Links in diff

I've just hacked up a small script: Gerbrant.edit.linksInDiff

This script searches the wikitext in the side-by-side comparisons (diffs) for things that look like internal links and makes them clickable. Exports nothing.

Shinobu 04:35, 5 October 2006 (UTC)

[edit] Yet another regex search and replace toy

See Gerbrant.edit.regexReplace. Documentation not yet available. Shinobu 06:40, 6 October 2006 (UTC)

Documentation is now available. In a nutshell: selectively replace text with other text using regular expressions, and possibly JavaScript to determine the replacement text. Shinobu 08:29, 11 October 2006 (UTC)

[edit] Godmode-light

..works fine but I can't get the automatic edit summary to work. Given that I'd like to make a run at adminship in the near future, I want to avoid oppose votes for edit summary usage. If anybody would know how to fix this, feel free to edit my monobook. User:Mike1/monobook.js. - Mike | Talk 23:44, 21 October 2006 (UTC)

[edit] Decache

Gerbrant.mng.decache (documentation) is the solution I use for the browser cache problem. It passes user-selected script(s) to an external application, that removes the scripts from the cache. It's considerably faster than Ctrl-F5, because the browser only reloads the selected script(s). If someone is interested, I have a working implementation of an external application to handle the decaching. Shinobu 11:17, 13 November 2006 (UTC)

[edit] Single or double quotes?

I noticed the instructions on this page use single quotes for strings. However, Java is supposed to have been based on C++. There you must use double quotes (") for strings. Single quotes (') represent a character with no end of string marker.

Which is correct here? Will (Talk - contribs) 02:56, 17 November 2006 (UTC)

This is JavaScript, not Java. In JavaScript, you can use both single and double quotes; see JavaScript syntax#Strings. -- Jitse Niesen (talk) 04:02, 17 November 2006 (UTC)

[edit] Can the sidebar stuff be displayed as drop menus along the top?

Please note the placement of the sidebar at Wikia:StarWars:User:Sikon. Specifically, it becomes a series of drop menus on the right. Is there some code I can add to my monobook.js to do the same thing for all pages that I view? I ask because I am stuck at 1024x768. I need to reclaim some more horizontal space. (It is worse at Wikia because they may you surrender some width to the Google ads.) I would also prefer that the drop menus and the top row of links (with the user page, talk page, watchlist, etc) be in a fixed frame. Will (Talk - contribs) 05:23, 17 November 2006 (UTC)

If I navigate to that site, I just see a normal sidebar on the left. However, if you want to "reclaim horizontal space", you may want to try this: hidePane It makes the sidebar really narrow (about three characters). When you mouse over, it opens, showing the full titles of the sidebar links. I use it because I like large fonts and small windows. Note that it has not been extensively tested yet. Shinobu 03:03, 12 December 2006 (UTC)

[edit] The installation instructions seem to be broken

Or rather, you don't seem to be able to use them on the module which they give as an example, Wikipedia:WikiProject User scripts/Scripts/Show last diff because somebody has put some uncommented non-javascript in the middle of it.

I'm guessing that users of that module since have just copied the js into their monobooks, but shouldn't the text be in a JS comment. However, I guess that means that the modified code should be in a different page.

This is the first time I've tried using any scripts, so I'm a bit put out to find out that the documentation doesn't work. Fortunately I'm familiar with debugging JS (and have Web Developer in my Firefox). --ColinFine

Looks to me like someone put another version into the page. Then again, I stick with C++/MFC and C#. Will (Talk - contribs) 04:51, 18 November 2006 (UTC)
In fact, quite a number of subpages of Wikipedia:WikiProject User scripts/Scripts are not well-formed JavaScript. So I commented out the installation instructions for the moment. Somebody has to either change them or go through all the subpages and make sure that text is converted to JavaScript comments where necessary. -- Jitse Niesen (talk) 05:37, 18 November 2006 (UTC)

I've restored the istallation instructions and expanded them to explain when you can and can't 'import' scripts. I've also edited 'Show last diff' to make it valid JS. --ColinFine 00:00, 27 November 2006 (UTC)

[edit] Tidy up

There are two bits of tidying up I want to do on this page.

sorting
I expect that this will be uncontroversial, but I wanted to check before doing it that it won't break anything. I'd like to sort the table of scripts alphabetically.
consistent naming
This one's a bit trickier because of 'import_module'. I would like to move some of the script files so that they have a consistent naming style (I'm thinking of 'Show last diff' vs 'hideOwn.js'). But I can't think of a way to do it safely, because even if 'import_module' were rewritten to resolve redirect pages, it wouldn't affect all the copies of 'import_module' on existing pages.

On the other hand, if it were possible to rewrite 'import_module' to follw redirects (is it?) we could rename the pages as long as it was the new name that was the redirect. Or could we?

Thoughts, anybody? --ColinFine 00:10, 27 November 2006 (UTC)

It might be more useful to sort the scripts by function, e.g. have a section for deletion-related scripts, a section for editing-related ones etc to make it easier to find the one you're looking for. It's probably best to leave the existing scripts as they are, to avoid breaking anyone else's monobook, since not everyone would be using the same techniques to import the ecripts. One possible solution might be to make a duplicate copy of the page at the new name, but this might be confusing to people, having two copies of the same script, which might end up being slightly different. Tra (Talk) 00:23, 27 November 2006 (UTC)
I'd say sort by function. As for naming, what about two columns, one for the name that describes the function, and the other for the page name at which the script is found? --ais523 08:40, 27 November 2006 (UTC)
Colin, you're my hero. The list definitely needs some cleanup. I'd vote for sorting by function or category, much like the meta-scripts are already in their own section. As for naming, I think that that doesn't matter that much. If the name is used to actually import the script, okay, but generally, the name is just for easy remembrance. This especially applies to those scripts that are not actually (safely) includable because they are on a page everyone can edit. Shinobu 17:22, 27 November 2006 (UTC)
I've sorted the list by function; as always, feel free to resort/change the categories it's sorted into or whatever. --ais523 09:34, 28 November 2006 (UTC)
I think the table columns need to be reorganized a little. The first column should be a direct link to the script, to make the process easier to explain to newbies, instead of "some link directly, and some don't, and you need to figure it out". We could then have a "Documentation" column which links to the script's subpage. Also, I think we need to change the phrase "helper function" to "library" throughout the article, as this more accurately reflects their content: they're scripts that contain helper functions, not functions themselves. We could then rename the "Required helper functions" column to "Dependencies". So, my suggestion is
! Links !! Summary !! Documentation !! Dependencies
Finally, we could condense the current lengthy installation instructions to a pretty 3-step table, a la WP:AfD. Supadawg (talk contribs) 22:59, 28 November 2006 (UTC)