Jump to content

Wikipedia talk:User scripts: Difference between revisions

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia
Content deleted Content added
→‎Calling akeytt(): akeytt(id) is broken, fixed in svn
Supadawg (talk | contribs)
Line 299: Line 299:


OMG! Why did you tell me to turn on the JavaScript console? Every page on the entire Internet gets JS errors. Every page at WP gets "Unknown property 'column-count'", many get "Error in parsing value for property 'color'" or "Error in parsing value for property 'border-style'", and things like that. Doesn't anyone check for errors? [[User:Barticus88|-- Randall Bart]] 22:13, 12 January 2007 (UTC)
OMG! Why did you tell me to turn on the JavaScript console? Every page on the entire Internet gets JS errors. Every page at WP gets "Unknown property 'column-count'", many get "Error in parsing value for property 'color'" or "Error in parsing value for property 'border-style'", and things like that. Doesn't anyone check for errors? [[User:Barticus88|-- Randall Bart]] 22:13, 12 January 2007 (UTC)
:Those are probably browser incompatibilities. They don't hurt anything, as they're just CSS. Nothing bad will happen with the console on. [[User:Supadawg|Supadawg]] ([[User talk:Supadawg|talk]] <small>•</small> [[Special:Contributions/Supadawg|contribs]]) 23:22, 12 January 2007 (UTC)

Revision as of 23:22, 12 January 2007


AutoAFD

The script don't capture correctly the pagename when there are accentuation on the title. Is there any way to fix it? --Giro720 00:07, 11 October 2006 (UTC)[reply]

  • I think it has to do with unescape(). For some odd reason, unescaping when the title contains an accented word causes weird characters to appear. AZ t 16:04, 24 November 2006 (UTC)[reply]

Project directory

Hello. The WikiProject Council has recently updated the Wikipedia:WikiProject Council/Directory. This new directory includes a variety of categories and subcategories which will, with luck, potentially draw new members to the projects who are interested in those specific subjects. Please review the directory and make any changes to the entries for your project that you see fit. There is also a directory of portals, at User:B2T2/Portal, listing all the existing portals. Feel free to add any of them to the portals or comments section of your entries in the directory. The three columns regarding assessment, peer review, and collaboration are included in the directory for both the use of the projects themselves and for that of others. Having such departments will allow a project to more quickly and easily identify its most important articles and its articles in greatest need of improvement. If you have not already done so, please consider whether your project would benefit from having departments which deal in these matters. It is my hope that all the changes to the directory can be finished by the first of next month. Please feel free to make any changes you see fit to the entries for your project before then. If you should have any questions regarding this matter, please do not hesitate to contact me. Thank you. B2T2 14:27, 26 October 2006 (UTC)[reply]

Need a tag for WikiProject Fan Fiction

...I have no idea where else to find someone to help me out with this without going to the main Help Desk, and that's usually a pain to edit. :\ Hopefully one of you can help?

Anyway, all I need is a tag - like most WikiProjects have already - to put on the Talk pages of articles that fall within the scope of WikiProject Fan Fiction. Can anybody here help out with this? Runa27 22:51, 26 October 2006 (UTC)[reply]

SON OF TWO STRANGERS. ARGH. >.< I TOLD that admin I was working on reinvigorating the project, and he STILL deleted it for being inactive! RIGHT after I added all those pages and started linking them to the project as the previous project runner had never done ... ARGH.
Give me a few hours and I shall restart it. It'll be at that location, don't worry. (Of course if the original founder still was at all active and had actually gotten all the appropriate articles tagged as being under the project, I wouldn't have to go through all this, but oh well). I have to go to dinner first with the family, but afterwards I shall fix this. Runa27 22:57, 26 October 2006 (UTC)[reply]
Actually you mispelled the link, which is why it is red; it still exists at Wikipedia:WikiProject Fan Fiction. As for the tag, look at existing templates like {{WPBooks}}. Create a template page, with a content similar to the following:
{| class="messagebox standard-talk"
|- style="vertical-align:top;"
| rowspan="3" width="50px" | [[Image:Open book 01.svg|60px]]
| colspan="2" style="font-style:italic;text-align: center;" |
This article is within the scope of '''[[Wikipedia:WikiProject Fan Fiction|WikiProject Fan Fiction]]'''. You can discuss the Project at its [[Wikipedia talk:WikiProject Fan Fiction|talk page]].
|}<includeonly></includeonly><noinclude>
[[Category:Fan fiction|*]]
</noinclude>

Take a look at Help:Template for more information AZ t 23:11, 26 October 2006 (UTC)[reply]

I've made a template at {{WikiProject Fan Fiction}}. Tra (Talk) 23:20, 26 October 2006 (UTC)[reply]

Help!

I need help with my scripts. Currently, only navigation popups and InstaView are enabled. Howver, there are a lot more scripts, which aren't working. Please look at my monobook.js and then fix it if you can, or leave a suggestion on my talk page. Thanks in advance, ςפקιДИτς 01:17, 31 October 2006 (UTC).[reply]

Replied on User talk:SFGiants. --ais523 15:11, 31 October 2006 (UTC)

Changes to accesskeys and tooltips

Mailing list thread. Apparently some planned changes in Mediawiki might break some user js, but I don't really understand. the wub "?!" 09:51, 6 November 2006 (UTC)[reply]

Replacing text through scripting

I have created a few scripts so that I am able to quickly assess articles of stub or start status for various Wikiprojects I am part of. My problem is that, as of right now, the only way for me to use the scripts is if there is nothing at all in the talk page besides the template in question (which my script then wipes out and replaces). Is there away to search for, say, {{WPBiography}} and replace only that with {{WPBiography|class=start|importance=low}} while keeping everything else intact? here is an example of one of my scripts:

// Code originally by [[User:Raylu|raylu]]
// Modified by [[User:Moeron]]
//
//
// This script adds a "stub,low" tab to the top of Article pages
// when in edit mode.

function docvg() {
  document.editform.wpTextbox1.value = '{{' + 'cvgproj' + '|' + 'class=stub' + '|' + 'importance=low' + '}' + '}';
  document.editform.wpSummary.value = 'Assessed as stub, low importance -- [[Category:Unassessed computer and video game articles|You can help!]]';
  document.editform.wpMinoredit.checked = false;
  document.editform.submit();
}

function addcvg() {
  addTab("javascript:docvg()", "cvg", "ca-cvg", "cvg", "");
  akeytt();
}

addOnloadHook(function() {
  if (document.title.indexOf("Talk:") != -1) {
  addOnloadHook(addcvg);
  }
});

Thanks for any help in advance. -- moe.RON Let's talk | done 22:04, 6 November 2006 (UTC)[reply]

You could try doing something similar to this and do a regexp replace on the article. Tra (Talk) 22:44, 6 November 2006 (UTC)[reply]
I am not very code literate, so, could you explain how I would use that script or point me where it is explained? -- moe.RON Let's talk | done 18:39, 15 November 2006 (UTC)[reply]
Try something like
document.editform.wpTextbox1.value = document.editform.wpTextbox1.value.split("{"+"{WPBiography}}").
  join('{\
{' + 'WPBiography' + '|' + 'class=start' + '|' + 'importance=low' + '}' + '}';
(for the example given above). --ais523 09:14, 16 November 2006 (UTC)
Or perhaps something like:
var tb = document.editform.wpTextbox1;
tb.value = tb.value.replace("{\
{WPBiography}}", "Some replacement text");
No clue about performance, perhaps less temporary strings or optimized implementation. Performance aside, it allows you to look for more complex patterns using regexen, if necessary. If you specify the global flag ( /....../g ) then it replaces all instances.
Please remove bugs (if any) before use. Shinobu 13:06, 21 December 2006 (UTC)[reply]

Try wiked. This in-page editor extension allows regular expression find and replace. You can also predefine find and replace texts which will be added to the drop-down history of the find and replace fields. Cacycle 16:29, 21 December 2006 (UTC)[reply]

Merge

Why merge? Wikipedia:Scripts seems to be about a wholly different sort of scripts. -- Jitse Niesen (talk) 00:47, 10 November 2006 (UTC)[reply]

The merge tag was subsequently changed by the same user to aim at Scripts (in article space), so I removed the tag as a WikiProject/article space merge would clearly be improper and lead to chaos. --ais523 16:13, 13 November 2006 (UTC)

On a separate note, someone started Wikipedia:Monobook, changing it from a previous redirect to MediaWiki:Monobook.css. The page is in bad need of cleanup; perhaps it should be merged w/ WP:US, WP:JS, or Wikipedia:WikiProject User scripts/Tutorial? Since there is also Special:Mypage/monobook.css, I don't know if that would be the correct merge to do though. AZ t 17:25, 3 December 2006 (UTC)[reply]

I'd support 'adopting' that page and moving it to a WikiProject subpage. --ais523 08:46, 4 December 2006 (UTC)

Arrows in edit summaries

At the moment, the software places a rightwards-pointing arrow on edit summaries generated by section edits and the contents of MediaWiki space place a leftwards-pointing arrow on autosummaries for redirecting, blanking, and replacing content (see WP:AES). Maybe it would be a good idea to have a standardised symbol on edit summaries generated by scripts and/or bots? --ais523 13:14, 4 December 2006 (UTC)

I've been using an autoedit script, and I've been thinking about adding a link to relevant MoS or other pages everytime it changes something. A standard symbol for scripts would a) make this more uniform and b) take up less space than a full link in the summary, which may after all contain the summary of a normal edit too. Possible are e.g. ⒮⒝ⓈⒷⓢⓑ, but these are not available in all fonts. In fact two of them are showing up as squares already. The same applies to other extended Unicode symbols, so perhaps it's better to use e.g. (s) for scripts and (b) for bots. Then my script would insert, say " (s) - ² d ", if it changed a dash, a superscript and a date, the first link pointing to the script itself, or its manual. Shinobu 18:23, 20 December 2006 (UTC)[reply]

Formatter is a nice small script useed by many users, but it doesn't seem to have a 'caretaker'. There are some suggestions on how to improve it on talk, but we don't have anybody to implement them - perhaps a person experienced with scripts could 'adopt' this script?-- Piotr Konieczny aka Prokonsul Piotrus | talk  21:28, 5 December 2006 (UTC)[reply]

I had a qick look and most of this script's functionality can be found in the fix buttons of wikEd. I would be happy to add suggestions to wikEd. Cacycle 22:05, 5 December 2006 (UTC)[reply]

Assistance with bureaucrat JS

Some time ago, Voice of All wrote a nifty little bureaucrat script that helps to close RfAs. Unfortunately, over time, it's become rather overfeatured, including several features that makes the job harder, rather than easier. Additionally, several bugs have developed, causing even more problems. At this time, I'm looking for a talented coder who can either adapt the existing code (located in the history of User:Essjay/bureaucrat.js), or write new code to do this, and only this:

  • Provide two tabs on RFA's: Success & Failure.
    • Success should add {{subst:rfap}} at the very top of the page, and {{subst:rfab}} at the very bottom. The link at the top of the page that says something along the line of "Say something here" (it changes rather frequently) should be removed, and replaced by the word "Final." "Ending" (or whatever it says that day) should be changed to "Ended." There should be an auto-edit summary of "Closed, promoted."
    • Failure should add {{subst:rfaf}} at the very top of the page, and {{subst:rfab}} at the very bottom. The link at the top of the page that says something along the line of "Say something here" (it changes rather frequently) should be removed, and replaced by the word "Final." "Ending" (or whatever it says that day) should be changed to "Ended." Auto-edit summary of "Closed, not promoted."
  • Clicking either of those tabs should open up the edit view of RFA. No annoying popups, no javascript to remove the listing, paint a stunningly realistic Monet, or scratch my back, just open the edit view of RFA so I can remove the listing.
  • Clicking success should open the edit view of the current "successful RFA's" page, whatever it is titled (there is a dicsussion about a change). Doesn't need to automatically add it, I can do that, just open the edit view.
  • Clicking failure should open the regular view of the main "unsuccessful RFA's" page; I'll pick the right archive from there.

That's all I need it to do; I don't need it to open up Special:Makesysop, the user's talk page, add comments to the RfA's talk page, check voting records, waive flags, or launch ICBMs at Willy on Wheels. From there, I can take the rest.

Thanks to whomever can take care of this for me. Essjay (Talk) 03:19, 11 December 2006 (UTC)[reply]

I've had a go at this; my attempt is currently in my script sandbox (User:ais523/sandbox.js). As you're requesting opening 3 pages, I've told it to open up the RfA mainpage and successful/unsuccessful RfA page in separate windows (it's not clear to me exactly what you're asking for there). Let me know what you think! --ais523 10:21, 11 December 2006 (UTC)
By the way, the script requires the libraries add LI link and add tab to work, both available at WP:US/S. --ais523 10:24, 11 December 2006 (UTC)
Thank you very much, you got it exactly! Thanks! Essjay (Talk) 01:40, 13 December 2006 (UTC)[reply]

How do I get Javascript to automatically send me to another page?

Yeah... Pretty much the heading. I have no idea, but I'd like to. -Amarkov blahedits 02:29, 23 December 2006 (UTC)[reply]

The key line looks like this:
location.href="http://en.wikipedia.org/wiki/whatever";
You'll also need code to set it off at the right timing. One very simple example is in User:ais523/monobook.js; it purges my userpage whenever I visit it (search for 'location.href='). --ais523 17:06, 23 December 2006 (UTC)
Also, for compatibility with bad browsers you should use window.location.href and in ais523's monobook there is the location.href relocating inside an addOnloadHook. If you just want to redirect someone on a certain condition, do not use addOnloadHook, because your page will have to load then redirect, which is very pointless. The only reason you should addOnloadHook a redirect is if you need the page to load before redirecting (like redirecting to one of the links on the page or something).
Well, my opinion for you hope it helped GeorgeMoney (talk) 19:06, 23 December 2006 (UTC)[reply]
Thanks, looks like what I want. Now I get to make it work with almost no knowledge of Javascript, yaaay. At least it's fun. -Amarkov blahedits 22:50, 27 December 2006 (UTC)[reply]

Okay, now how do I set up things to execute one after another?

The functions are executing on the page I'm currently on. How do I make it go to the other page before trying to execute the stuff? -Amarkov blahedits 01:24, 29 December 2006 (UTC)[reply]

What? You need to give more detail on what exactly you're trying to do. What is the "other page"? Which functions are you using? They should be executing one after another in the order they appear in your monobook.js. Supadawg (talk contribs) 04:11, 29 December 2006 (UTC)[reply]
Okay, so my question made no sense. Sorry, I was tired. -Amarkov blahedits 17:18, 29 December 2006 (UTC)[reply]
I'd be happy to help; just repost your question with details. Supadawg (talk contribs) 19:28, 29 December 2006 (UTC)[reply]
I'm trying to get something to go to another page, and then edit some of the objects there. The problem is, it tries to do the other actions before going to the page, which obviously does not work; most of the things I try to edit don't exist on the page I'm on. So how do I get it to go to the other page first? -Amarkov blahedits 21:09, 29 December 2006 (UTC)[reply]
Assuming you're talking about the aivreport function in your monobook.js, it needs to be done in two parts.
  1. Do the redirect and nothing else
  2. Detect when you've hit the page you redirected to and do whatever action it is you want to do
This is something like the "autoedit" trick done by Lupin's popups.js. It adds extra URL parameters to the redirect URL and then detects those parameters after the redirect has taken place. This is how it knows to substitute redirects and such. Detecting when to trigger the automated action can be done with any portion of the URL string, including custom parameters. Mike Dillon 23:09, 29 December 2006 (UTC)[reply]
Ohhhh, that makes sense. Thanks. -Amarkov blahedits 23:12, 29 December 2006 (UTC)[reply]
Now I need to figure out how to get variables to save across pages. Any ideas? -Amarkov blahedits 06:58, 30 December 2006 (UTC)[reply]
There are two main methods: add parameters to the URL (as used by User:ais523/editcount.js; this method doesn't work from an edit page to the page that results after the save), or to use cookies (I've never used this technique, but I've seen scripts that do; I seem to remember there were cookies in Cacycle's wikEd script). --ais523 14:29, 30 December 2006 (UTC)
It can be made to work with the edit form, but you need to add hidden form elements to the DOM. There may be browser specific quirks, but it works in Mozilla 1.7 and Firefox at least. Or are you referring to the server-side redirect that happens after the save is actually completed? Mike Dillon 16:28, 30 December 2006 (UTC)[reply]
Okay, no idea how to do cookies, so I'm going to stuff the URL. It'll make it long, but oh well. -Amarkov blahedits 16:35, 30 December 2006 (UTC)[reply]
(In reply to Mike Dillon) Yes, I was referring to the server-side redirect, which junks any user parameters in the URL. --ais523 16:38, 30 December 2006 (UTC)
Argh, now I don't know what's wrong. For some reason, the tab does not feel like showing up now. The code is at User:Amarkov/aiv.js if anyone wants to help. -Amarkov blahedits 17:13, 30 December 2006 (UTC)[reply]
Have a look at User:Mike Dillon/Scripts/aiv.js. It adds the tab for me when on a "User talk" page and the makereport() function ends up executing once on the page. I'm not sure what exactly you were trying to do with makereport, so it looks like that still needs some work. I may have misunderstood what you are trying to do with this. Mike Dillon 17:40, 30 December 2006 (UTC)[reply]
I see what you're trying to do. Let me see if I can get it to work. Mike Dillon 17:44, 30 December 2006 (UTC)[reply]
OK. Check it out now. I believe it does what you want. I also made it so that you can type whatever you want into the "Reason?" prompt. Mike Dillon 17:49, 30 December 2006 (UTC)[reply]
Thanks! It seems to work fine. -Amarkov blahedits 18:05, 30 December 2006 (UTC)[reply]
Cool. I made a change after you copied it to allow you to choose whether it opens in a new window or not. Mike Dillon 18:10, 30 December 2006 (UTC)[reply]

Wikipedia Day Awards

Hello, all. It was initially my hope to try to have this done as part of Esperanza's proposal for an appreciation week to end on Wikipedia Day, January 15. However, several people have once again proposed the entirety of Esperanza for deletion, so that might not work. It was the intention of the Appreciation Week proposal to set aside a given time when the various individuals who have made significant, valuable contributions to the encyclopedia would be recognized and honored. I believe that, with some effort, this could still be done. My proposal is to, with luck, try to organize the various WikiProjects and other entities of wikipedia to take part in a larger celebrartion of its contributors to take place in January, probably beginning January 15, 2007. I have created yet another new subpage for myself (a weakness of mine, I'm afraid) at User talk:Badbilltucker/Appreciation Week where I would greatly appreciate any indications from the members of this project as to whether and how they might be willing and/or able to assist in recognizing the contributions of our editors. Thank you for your attention. Badbilltucker 19:36, 30 December 2006 (UTC)[reply]

Proposal

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 03:01, 5 January 2007 (UTC)[reply]

I'm not sure what you're asking exactly. Are you trying to add this for everyone, or just publicize the code? If the former, it should be discussed at Wikipedia:Village pump (technical) first and then proposed at MediaWiki talk:Common.js. I personally don't think it should be added site-wide. If you're trying to publicize it, it should be added to Wikipedia:WikiProject User scripts/Scripts. You can either add it yourself (with the addlilink dependency called out but not included), or propose it at Wikipedia talk:WikiProject User scripts/Scripts. Mike Dillon 17:13, 6 January 2007 (UTC)[reply]
I'm just trying to publicize it. I'll post it at the talk page. John Reaves 05:16, 7 January 2007 (UTC)[reply]

Math in Javascript?

Heading is pretty obvious; how do I do it? -Amarkov blahedits 16:13, 6 January 2007 (UTC)[reply]

This page is a pretty good reference: JavaScript tutorial - Operators. It's generally pretty transparent, depending on what you're going for. Mike Dillon 17:16, 6 January 2007 (UTC)[reply]
Oh, wow, that's more transparent than I thought. I'm just trying to add 1, actually, so it's pretty easy. I assumed that since + is used for other purposes, it wouldn't work. -Amarkov blahedits 19:26, 6 January 2007 (UTC)[reply]
Okay, so now I need to know how to convert from a string to a number and back. The way I have doesn't work. -Amarkov blahedits 20:50, 6 January 2007 (UTC)[reply]

There are a number of ways to do these things. Some may be browser specific.

String to number:

    var num;
    var str = "1";

    num = +str;
    num = str * 1;
    num = new Number(str);

Number to string:

    var str;
    var num = 1;

    str = "" + num;
    str = new String(num);

One of those should work. Mike Dillon 21:32, 6 January 2007 (UTC)[reply]

Okay, I think that works fine. The problem I have must be with extracting the number from the edit window. Saving the page seems to add a return character, which I suspect is throwing it off, but I do not know how to fix that. -Amarkov blahedits 21:45, 6 January 2007 (UTC)[reply]
You can trim the string by calling str = str.replace(/^\s+|\s+$/, ""). However, I think your problem is that you don't have an ampersand in front of your "fakeparam". Mike Dillon 21:50, 6 January 2007 (UTC)[reply]
There was a dropped ampersand in a later function, but that shouldn't have affected it, I don't think. -Amarkov blahedits 21:52, 6 January 2007 (UTC)[reply]
Yeah, it was in "movepage()". The replace code above will remove a trailing newline, but I tested converting "1\n" into a number without trimming and had no problems. Mike Dillon 21:54, 6 January 2007 (UTC)[reply]
Which explains why it still fails. Argh. -Amarkov blahedits 21:56, 6 January 2007 (UTC)[reply]
Okay, so the problem, I think, is that URL parameters do not work properly out of "/w/index.php?" I might be able to manage around that. -Amarkov blahedits 22:06, 6 January 2007 (UTC)[reply]
There's still a problem. Argh. -Amarkov blahedits 22:13, 6 January 2007 (UTC)[reply]
Are you talking about getarchivenumber() in your monobook.js? What do you expect it to do? Changing location.href after clicking the submit on the edit form won't work. Mike Dillon 22:23, 6 January 2007 (UTC)[reply]
I expect it to submit the form and then change pages. That may not work correctly, but the problem is that it doesn't even get that far. It stops before executing the first line; actually, just loading the page, running the javascript or not, freezes it. -Amarkov blahedits 22:31, 6 January 2007 (UTC)[reply]

So it looks like this is what you're trying to do:

  1. Get the current archive number from User:Amarkov/archivenumber
  2. Increment the archive number by one and update User:Amarkov/archivenumber
  3. Move User talk:Amarkov to User talk:Amarkov/Archive $N where "$N" is the new archive number
  4. Replace the contents of User talk:Amarkov with some boilerplate text

I'm pretty sure you can't do this. The main problems are that it is not possible to control the URL that is redirected to after you save the new archive number, or the URL you end up at after the page move. It would be possible to do this using AJAX, but I don't know if any reusable code for dealing with the edit box or page move using AJAX. Writing this code yourself is beyond your abilities in this area, as I'm sure you know. It's also possible that this could be done with some sophisticated cookie handling code to maintain the state between steps, but that's also quite difficult for an inexperienced programmer. Mike Dillon 02:13, 7 January 2007 (UTC)[reply]

Oh, I see what you mean. I guess I can deal with manual archiving. -Amarkov blahedits 02:15, 7 January 2007 (UTC)[reply]
P.S. Why not try something like Werdnabot? I know it doesn't use the same mechanism for archiving (i.e. it transfers comments instead of moving the page), but it does its job quite well. Mike Dillon 02:15, 7 January 2007 (UTC)[reply]

So, I remembered that Quarl had some AJAX based editing code at User:Quarl/wikiedit.js. I've never used it, though, so I can't give any advice on how to accomplish what you're trying to do. I believe it would work, though. Mike Dillon 02:36, 7 January 2007 (UTC)[reply]

Calling akeytt()

The akeytt() function is generally one of the slowest parts of the page load when called with no arguments (taking about 20-50% of the JavaScript execution time from what I've seen). I've noticed that a lot of the functions at Wikipedia:WikiProject User scripts/Scripts call akeytt() after any call to addlilink(). Since these things are generally being done in a function passed to addOnloadHook(), this is totally unnecessary, since runOnloadHook() calls akeytt() itself.

The only time that akeytt() should be called is for things that execute after runOnloadHook() and in those cases it should only be called if a new link that actually has an id is added to the page. If it is called in those cases, it should pass the id to the function instead of calling it with no arguments to allow the function to avoid reinitializing access keys for all of the other links in the ta[] array. I have changed Wikipedia:WikiProject User scripts/Scripts/Add LI link to only call akeytt() if the link being added has an id and I changed it to pass that id to the function instead of calling it without any arguments. Mike Dillon 20:15, 6 January 2007 (UTC)[reply]

Unfortunately, runOnloadHook() calls akeytt() before calling any custom hooks, so generally user scripts will need to call akeytt() themselves. Also, you modified version probably doesn't currently work, since akeytt(id) is broken in the version of wikibits.js currently used on Wikipedia. I just committed a fix for that, but it isn't live yet, and won't be until someone syncs the servers, which may take a few days or, possibly, weeks. —Ilmari Karonen (talk) 23:21, 12 January 2007 (UTC)[reply]

Why is my toolbox item doubled?

Howdy! I have been programming since we punched holes in paper, but I only took up JavaScript this year. I don't know where to ask JS questions, so I'm starting here. I have written two scripts:

  1. User:Barticus88/dpl.js, which adds selection mode buttons to the toolbox on What links here pages (used by disambiguation)
  2. User:Barticus88/edit_section_zero.js, which adds an edit section zero button to "edit this page" (used by everybody)

Both scripts work perfectly, individually. However, no matter which way I arrange User:Barticus88/monobook.js, the "Mode: DPL T P R W U" line appears in the Toolbox either twice or not at all. Currently I have edit_zero last so it shows up twice. I don't see how one impacts the other. They're fiddling totally unrelated parts of the page. Both use addOnloadHook, but there are scripts that use addOnloadHook several times. -- Randall Bart 09:16, 10 January 2007 (UTC)[reply]

There's an error in the section-zero script; document.getElementById(something that doesn't exist).length is an error. You want to check if the button is null, rather than for having a zero length. I'm not sure whether its that error that's causing the doubling, but errors are a common cause of doubling. (You can find out about the error by double-clicking the 'warning' icon in the bottom-left corner of the screen in Internet Explorer, by typing 'javascript:' in the URL bar in Netscape, and I don't own a copy of FireFox but I'm sure it has an even better way of reporting JavaScript errors.) --ais523 09:22, 10 January 2007 (UTC)

Thanx. I sussed that myself a few minutes ago, after I realized how my edit zero was mangling other special pages. It worked fine when it found ca-edit, but when it didn't.... I saw that pattern and zeroed in on the problem. Well thanx for the quick response. So what do you think of my edit zero script? It's crude (it depends on the exact number of letters in "edit this page"), but I just started JavaScript, and I never did XML in any language. You have to admit it's a tight piece of code.

I have been hanging out at Wikipedia:WikiProject Disambiguation, but I'm going to start hanging out here. I've been programming since I had to dial the phone myself and hand it to the computer, but I am currently unemployed. I think I have a more profitable future as a JavaScripter than a disambiguator. -- Randall Bart 10:42, 10 January 2007 (UTC)[reply]

Your code seems to make it impossible to edit the entire page without hacking the URL; sometimes, a full-page edit is desirable, so I wouldn't use that script personally. If you're interested in writing User Scripts, it's probably worth pointing out that some of the documentation in this WikiProject is out of date; things like 'Get tidy title' are no longer useful because there are now variables provided automatically on each page (view the HTML source of any Wikipedia page for details). --ais523 10:55, 10 January 2007 (UTC)

Look more closely; there's a += not an =. My script piggybacks a second option on the same tab (two <a>s in one <li>). Variables: You mean the stuff following *<![CDATA[* is there for me to use? Thanx for pointing me there before I started chiseling those pieces from the url. Using the right variables improves portability. I shall rebuild this script using those variables, and add some bells and whistles. Actually just adding two whistles and retooling one bell. -- Randall Bart 22:14, 10 January 2007 (UTC) I am puzzled by wgArticlePath = "/wiki/$1". Shouldn't it be "/wiki"? How do I use this to build a URL? -- Randall Bart 22:49, 10 January 2007 (UTC)[reply]

OMG! Why did you tell me to turn on the JavaScript console? Every page on the entire Internet gets JS errors. Every page at WP gets "Unknown property 'column-count'", many get "Error in parsing value for property 'color'" or "Error in parsing value for property 'border-style'", and things like that. Doesn't anyone check for errors? -- Randall Bart 22:13, 12 January 2007 (UTC)[reply]

Those are probably browser incompatibilities. They don't hurt anything, as they're just CSS. Nothing bad will happen with the console on. Supadawg (talk contribs) 23:22, 12 January 2007 (UTC)[reply]