Wikipedia talk:WikiProject User scripts/Scripts/Archive

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)
Thanks for tidying the list up! It's a lot friendlier now. Shinobu 07:59, 14 December 2006 (UTC)

[edit] Script to welcome new users

I welcome new users all the time. However, it would be helpful if a script could add a "Welcome this user" to each entry in the user log. This link would also appear in the enhanced recent changes page (which expands the user log entry to show recently added users). One click and you have welcomed them. Nothing wouldh happen (other than maybe a dialog) if the talk page for that user turns out to be non-blank. The dialog, if used, could ask the user if they want to welcome the user anyway. This would let them welcome users that already have warnings. (Rare, but it happens.) -Will Pittenger 08:03, 14 December 2006 (UTC)

I think you can welcome useing AWB... maybe that would do what you want? ---J.S (T/C) 22:39, 14 December 2006 (UTC)
Or you could have the browser automagically navigate to the user's talk page and put in a welcome notice. Or you could try something AJAX'y... Are you any good with JavaScript? Would you rather wait until someone finds the time to code it (could take ages, some of us actually have things to do outside of Wikipedia) or would you rather have some information on how to do stuff and hack it up yourself, tweaking it to your own exact needs? Shinobu 23:08, 14 December 2006 (UTC)

The closest I come to Java experiance is a little bit of C#.NET and some serious C++/MFC. In both cases, my programs were stand-alone on a user machine (rather than a server) with no required browser. (Some did use IE inside dialogs, but not in any code I worked on.)

As for as AWB is concerned, it is not an option. My own computer is down for the forseeable future. That leaves with with a computer that I have little or no control over what is on it. (Besides, I would use the disk space on this machine up in a hurry.) -Will Pittenger 03:19, 15 December 2006 (UTC)

In case you want to overcome some JavaScript cold water fears, have a look at Wikipedia:WikiProject User scripts/Techniques, especially automatic editing. You can also add extra parameters to a Wikipedia url that Wikipedia itself doesn't use, but that your script uses - that's useful too. But even better would perhaps be reading and writing the wikitext of the page using AJAX, but I don't know how to do the writing part yet. Shinobu 01:03, 20 December 2006 (UTC)

Any development environment I use must be web-based. Same problem as with AWB. Will (Talk - contribs) 06:13, 20 December 2006 (UTC)

George Money is working on User:GeorgeMoney/UserScripts/autowelcome. Once the bugs are wrong out, this will do what I was looking for. I am helping George find the bugs. Will (Talk - contribs) 06:15, 26 December 2006 (UTC)

[edit] importScript() and importStylesheet() added to Mediawiki:Common.js

Hi all. I just wanted to point out for all those who don't watch Mediawiki:Common.js that two useful functions were recently added site-wide:

  1. importScript(): Imports JavaScript modules or libraries
  2. importStylesheet(): Imports CSS stylesheets

The addition of importScript() should make it unnecessary for people to keep copying the import_module() function to their personal JS files or creating their own versions. The version added site-wide is pure DOM and uses wgScriptPath to avoid hard-coding anything except the name of the "index.php" script. If you have any suggestions, please make them at Mediawiki talk:Common.js#Import Module. Thanks to AzaToth and R. Koot for making this available site-wide. Mike Dillon 18:50, 31 December 2006 (UTC)

Finally! Updated installation instructions on the main page. Supadawg (talk contribs) 20:27, 31 December 2006 (UTC)

[edit] Add purge tab

I try to use the script in another site, and installed the script at my JS page and addLink, but it wasn't work. Anybody has suggestion why? Troll Refaim 20:52, 3 January 2007 (UTC)

Which site are you using it on? Tra (Talk) 21:35, 3 January 2007 (UTC)
My local site, it isn't accessible by through the net. Troll Refaim 19:55, 13 February 2007 (UTC)
In that case, what code did you copy over? Tra (Talk) 20:20, 13 February 2007 (UTC)

[edit] New pages link in the navigation sidebar

Where is the appropriate place to add the script below?

addOnloadHook(addnav)
function addnav() {
    var tb = document.getElementById('p-navigation').getElementsByTagName('ul')[0];
    addlilink(tb, '/wiki/Special:Newpages', 'New pages', 'n-newpages', 'Special:Newpages', '');
}

function addlilink(tabs, url, name, id, title, key){
    var na = document.createElement('a');
    na.href = url;
    na.appendChild(document.createTextNode(name));
    var li = document.createElement('li');
    if(id) li.id = id;
    li.appendChild(na);
    tabs.appendChild(li);
    if(id)
    {
        if(key && title)
        {
            ta[id] = [key, title];
        }
        else if(key)
        {
            ta[id] = [key, ''];
        }
        else if(title)
        {
            ta[id] = ['', title];
        }
    }
    // re-render the title and accesskeys from existing code in wikibits.js
    akeytt();
    return li;
}

It adds a "Newpages" link in the navigation sidebar. John Reaves 05:18, 7 January 2007 (UTC)

Make a subpage of the scripts page and add a reference in the scripts table. Use the one of the other scripts as a model. Supadawg (talk contribs) 01:13, 8 January 2007 (UTC)


[edit] -date templates

Wikfy-date and cleanup-date are now redundant - Wikify and Cleanup do the job. Rich Farmbrough, 11:08 10 January 2007 (GMT).

[edit] Script for soft redirects

var MySoftRedirectLink;

function MyRedirect()
{
   var theSpan = document.getElementById("SoftRedirect");
   if (!theSpan) return;
   var message = document.createTextNode(" Redirecting in 5 seconds.");
   theSpan.appendChild(message);
   if(theSpan.getElementsByTagName("a")[0]) {
       MySoftRedirectLink = theSpan.getElementsByTagName("a")[0];
       setTimeout("location.href = MySoftRedirectLink.href",5000);
   }
}
addOnloadHook(MyRedirect);

I wrote this for myself in addition to adding the necessary #SoftRedirect to {{softredirect}}, so I don't know if there's any style guide [use of global variables, timers, etc] that applies in here —Random8322007-01-24T19:58:01UTC(01/24 14:58EST)

[edit] Twinklefluff

It's mostly ready now, perhaps some minor modifications left, dunno then where to put them in the lists. see Wikipedia:WikiProject User scripts/Scripts/Twinklefluff AzaToth 20:17, 24 January 2007 (UTC)

When I was sorting the scripts, I put rollback scripts in 'shortcuts for commands', because it's just a fast way of doing a revert. --ais523 09:18, 25 January 2007 (UTC)

[edit] Category:Wikipedia scripts

Please make sure to tag all pages with script with this category.-- Piotr Konieczny aka Prokonsul Piotrus | talk  20:43, 10 February 2007 (UTC)

[edit] User's groups tab

I used to have a small tab with a '$' in it that showed a user's groups (i.e. Admin, Bureaucrat, etc) when clicked. I'm sure where I got it or where it went, but does anybody know of a script that does this? John Reaves (talk) 07:21, 5 March 2007 (UTC)

I haven't seen this script, but it probably makes use of Special:Listusers with the username associated with the current page and a size limit of 1. The resulting link would be something like http://en.wikipedia.org../../../../articles/l/i/s/Special%7EListusers_21e7.html. Mike Dillon 02:07, 8 May 2007 (UTC)

[edit] AutoAFD problem

I put the AutoAFD script into my monobook and upon saving and refreshing etc, I noticed that the page was suddenly put up for deletion! I have since deleted the script as a result. What did I do wrong so I can re-add it to my monobook.

PS. If you want to have a look at the monobook then beware, it is a bit of a mess with alot of other codes in. I find it impossible to add other scripts to it now. - Erebus555 19:17, 7 March 2007 (UTC)

In the line that says t.value = "{{db|" + type + "}}\n" + t.value;, change "{{db|" to "{{d"+"b|", to prevent it transcluding {{db}}. --ais523 09:26, 8 March 2007 (UTC)

[edit] Internationalization and cross-project script reuse

Hi all. I've been working on a simple JavaScript library for internationalization and localization of user interface messages. The code can be found at User:Mike Dillon/Scripts/i18n.js. The library provides the following functions:

  • wfAddMsg(lang, key, value)
  • wfMsg(key)
  • wfMsgForContent(key)

The functions and their names were somewhat inspired by the way that MediaWiki itself handles i18n/l10n internally. The wfAddMsg function is used to add key/value pairs to the wgMessageCache object for a particular language code. The wfMsg and wfMsgForContent functions are used to fetch values for a particular key. As in MediaWiki itself, wfMsg takes both the user language (wgUserLanguage) and the content language (wgContentLanguage) into consideration while wfMsgForContent uses only wgContentLanguage. Both functions support the "$N" syntax used for placeholders in the MediaWiki system messages.

The mode of interaction between these functions and other user scripts means that the message keys can be pretty easily localized outside of the core script. This makes it easier to share scripts across projects in different languages without having to signficantly alter the script itself. If a library such as this one were put into wide use and combined with an enhanced version of importScript that could pull in scripts from different language Wikipedias and other MediaWiki installations, it could allow wider use of scripts that implement generic extensions to the MediaWiki interface. Some scripts will remain specific to the policies and community structure of a particular wiki, but many utility scripts are not.

If you're interested in seeing an enhanced version of importScript to allow cross-project imports, please comment at MediaWiki talk:Common.js#Enhancements to importScript. Mike Dillon 02:05, 8 May 2007 (UTC)

[edit] Help..

I want to replace certain words with other words. How do I do this in javascript? Like, say I didn't like the word "backback" and I wanted each instance of it to be replaced with "knapsack". -Indolences 23:27, 14 May 2007 (UTC)

Wikipedia:WikiProject User scripts/Scripts/Replace is what you want. It's a handy regex tool as well as normal search and replace :) Will (We're flying the flag all over the world) 03:06, 15 May 2007 (UTC)

This is how to do it in javascript (don't forget the "string = " part):

string = string.replace(/backback/gi, 'knapsack');

You might want to check the Wikipedia editor extension wikEd, it has powerful search and replace functions. Cacycle 03:42, 15 May 2007 (UTC)

Thank you for you help. I put it here but when I view the backpack article it still says "backpack" all over the page. -Indolences 23:48, 15 May 2007 (UTC)
You probably do not want to program it yourself, it is a bit more complicated than that. Use wikEd (or the Replace user script) to replace text in articles. Cacycle 01:58, 16 May 2007 (UTC)
"only for Firefox and other Mozilla browsers". I use IE :(. Thanks anyway. -Indolences 02:04, 16 May 2007 (UTC)
Perhaps you might want to try this. It has not extensively been tested by other users though. Shinobu 08:06, 2 July 2007 (UTC)

[edit] Notice

Either Firefox 2.0.0.4 or new software in Wikipedia has done the job of the script that makes long diffs have scroll bars. Could someone who (1) has logged out and (2) doesn't have the new version of Firefox test this? Link to long diff Thanks, IP 21:37, 4 June 2007 (UTC)

This was changed in MediaWiki, on diff page there are now div's inside cells, and there is overflow:auto on those divs in (also new) external diff.css file. So it's all just CSS, no Javascript involved here. — Alex Smotrov 23:16, 4 June 2007 (UTC)

[edit] Auto AFD

Adding this template to the end of my script generates a Javascript error "missing name after . operator" in IE and Firefox.

The line in the script that generated the error is: <pre>':{{la|' . target . '}} – <includeonly>([[Wikipedia:Articles for deletion/' . target . '|View AfD]])</includeonly>\n'+</pre>

The script was added via this line in monobook.js: importScript('Wikipedia:WikiProject User scripts/Scripts/AutoAFD.js');

Suggestions? Antonrojo 04:58, 11 June 2007 (UTC)

Someone's confused JavaScript with either PHP or Perl. The concatenation operator in Javascript is +, not .. --ais523 11:01, 11 June 2007 (UTC)