Wikipedia talk:WikiProject User scripts
|
|
Archives |
|---|
[edit] Recommendation
Which monobook would recommend for a firefox user? --Nemissimo 09:52, 18 September 2007 (UTC)
- It's not like there are only a few combinations of scripts you're allowed; you can have as many or few of the scripts here that you like. My recommendation is that you look through our scripts list and install all the scripts that you think you will find useful. (Which ones are useful for you will depend on your editing pattern.) --ais523 16:28, 18 September 2007 (UTC)
<:: If you want a whole bunch of scripts at once, try installing User:Pyrospirit/scriptpackage.js. It contains 20 various scripts all in one page, with editing, tagging, interface, meta-data and anti-vandalism scripts. The individual scripts it uses can be found in this WikiProject. However, if you want more customized scripts, just look around and find which ones look useful. I'd personally recommend wikEd and Twinkle. Pyrospirit (talk · contribs) 19:47, 14 October 2007 (UTC)
-
-
- Yep. 69.143.226.129 (talk) 09:57, 4 March 2008 (UTC)
-
[edit] Scripts misread by MediaWiki
I've noticed quite a few cases of scripts not taking into account MediaWiki's interpretation of the script. See Special:Whatlinkshere/" + target + " for what I mean. Since I'm not an admin, I can't do anything about those, but someone should really fix these things with <nowiki> tags or changing "[[" to "[" + "[" and such. Pyrospirit (talk · contribs) 19:59, 14 October 2007 (UTC)
- Yes, Whatlinkshere and categories "count" .js and .css pages as well. Yes, if the script was unintentonally added to a category it should be fixed. But I don't see a big problem with Whatlinkshere cases ∴ Alex Smotrov 23:37, 14 October 2007 (UTC)
- Perhaps MediaWiki needs to be changed in such a way that only comments can get interpreted like that. Shinobu 16:21, 4 November 2007 (UTC)
[edit] New version of hidePane.js
Good news for those of us who have limited screen real estate, or who simply like to use it more efficiently. I've updated User:Gerbrant/hidePane.js - instead of the ugly (although functional) gutter on the left hand side it now shows a series of pull down menu's at the top. This is also useful if you are primarly a Wikipedia reader, since all the space used by the left pane that contains the navigation, interaction, etc. portlets will be available for the actual article content. Of course the downside is that actions that normally take one click, now require you to open the appropriate menu. Perhaps in the future I'll add a way to active the most commonly used menu items in one click. Compatible with Safari (although wrapping doesn't work, but that's not my fault), IE and Firefox. If you have any feedback, please let me know. Shinobu 04:51, 4 November 2007 (UTC)
[edit] Regarding the to-do list...
- Create a "bare bones" monobook script that is standardized, easy to read, well commented, and based on functions.
- What does this mean? A bare bones monobook script would be an empty script without anything, functions or ortherwise, in it, no? In the end, what scripts you want to use depends on your taste and needs.
- Create a list of functions that will interact well with the standard.
- What standard? Monobook? I expect almost all scripts will work well on monobook, since almost everyone is using that.
- Last time I checked this was a while ago, so I'm not sure if this is still true, but in some other skins a script written for Monobook couldn't find HTML elements because they were for example called differently. It is often easier to simply customise monobook, then you're also certain all your scripts keep working, and you don't have to update your js and css.
- What standard? Monobook? I expect almost all scripts will work well on monobook, since almost everyone is using that.
- Test for incompatible user scripts and note this in the scripts list.
- That would be useful, but it would also entail a lot of work. Since it isn't like user scripts are extremely popular, the payoff will be small. Perhaps it's better to kindly ask people trying scripts to note any incompatibilities they encouter, but even then I don't really see the benefit. Most of the time someone encountering an error in a script will contact the writer of the script to have it fixed. Shinobu 18:44, 4 November 2007 (UTC)
[edit] Updated edit top script
Gerbrant.edit.top has been updated; I hope I didn't break anything. I fixed a bug, tried to make it more robust and also gave it a minor facelift. Shinobu 13:26, 12 November 2007 (UTC)
- Still, I don't really need [edit] link on pages that I cannot edit. Why don't you admit that checking for existing [edit] link is a better idea? :) ∴ AlexSm 18:24, 12 November 2007 (UTC)
Admit? It isn't like I ever denied it. :-) But your script doesn't seem to show an [edit] link for pages containing only the introduction. An [edit] link on such pages may be superfluous for most users, but it's still inconsistent. To solve this, you would need no have some extra checks in the case no existing [edit] link is found, not unlike mine. I do think your solution is more elegant, but for my needs my version works better, even if it is ugly. Shinobu 07:19, 13 November 2007 (UTC)
[edit] AfDsorting script help?
I'm working on a script to add a sort link to the top of the edit page for Articles for Deletion. When editing such an article, the sort button asks for a category code and a reason for sorting (sorting as whatever), then produces the appropriate template and code, adds the reason to the edit summary, and submits the edit. I've based it on Digitalme's AIV Helper, paring down the function to just one button.
However, three problems exist. First, I can't get it to automatically take the single-letter code for the category (per CAT:AFD and generate an automatic edit summary. Second, the sorting template (REMOVE WHEN CLOSING THIS AFD) is generally placed on the second line, under the heading for the debate. I can't get the script to place the template anywhere other than the end of the page. This means that the existing template must be deleted by hand. Third, I don't know how to have the script remove any existing sorting templates (such as nominator unsure, for example). The script in its current form may be found here. Thanks in advance for any advice you can provide. ZZ Claims ~ Evidence 20:16, 15 November 2007 (UTC)
If this request goes elsewhere, please let me know. Thanks! ZZ Claims ~ Evidence 20:17, 15 November 2007 (UTC)
- In order to add things to the right point in t.value, you have to come up with a rule to decide where to add the tag. In this case, I'd suggest adding the tag after the second occurrence of ===, which I'd do like this:
if(t.value.split("===").length>=3) { var a=t.value.split("==="); a[2]="\nTEXT TO ADD HERE"+a[2]; t.value=a.join("==="); }
- There are several ways to do this in JavaScript, though; the split/join is the method that I normally use, but other people use different methods.
- As for removing a previous tag, this method comes directly from the source code of User:Bot523, modified to fit into code which uses the same variable names as Digitalme's code:
t.value=t.value.split("{{REMOVE THIS TEMPLATE WHEN CLOSING THIS AfD|").join("{{ns:0|");
- ({{ns:0}} is a magic word that always expands to the null string.) Come to think of it, {{subst:ns:0}} would possibly work even better, so as to remove the template altogether on page save. There are also methods which parse the page's wikimarkup to remove the template.
- As for changing the edit summary, with the variable names that Digitalme's code uses, that's just
f.wpSummary.value, which you can set to whatever you like to change the edit summary. Hope that helps! --ais523 13:26, 16 November 2007 (UTC)
-
- Please doublecheck me, but based on your input, I think I have it working properly. I still can't get the edit summary to reflect the code input, so I simplified it to a generic "sorting per CAT:AFD" note. Thanks for your assistance! I've put together instructions and notes on the script here, and the completed (hopefully) code is here. Again, Thanks! ZZ Claims ~ Evidence 16:01, 16 November 2007 (UTC)
-
- In its current form, it adds a line between the heading and the debate itself. I can accept this, even though I'm sure it's easily fixable and I'm missing something. ZZ Claims ~ Evidence 18:04, 16 November 2007 (UTC)
- What seems to be happening is that both the newline before and the newline after the {{REMOVE THIS TEMPLATE... line are being preserved. Try writing
\njust before the opening {{ inside each of your split-strings; that will cause the initial newline to also be deleted, getting rid of the extra space. --ais523 14:30, 19 November 2007 (UTC)
- What seems to be happening is that both the newline before and the newline after the {{REMOVE THIS TEMPLATE... line are being preserved. Try writing
- In its current form, it adds a line between the heading and the debate itself. I can accept this, even though I'm sure it's easily fixable and I'm missing something. ZZ Claims ~ Evidence 18:04, 16 November 2007 (UTC)
-
-
-
- I figured it out - I needed to add both an /n for the new line and a /r for the carriage return. It's fixed and working well. I've also added a second script that removes the sort template entirely. I've been using that one to remove the sort template from closed debates, to take them out of the categories used for the open debates. Thanks again for the help! The scripts may be found here. UltraExactZZ Claims ~ Evidence 21:15, 28 December 2007 (UTC)
-
-
[edit] Adding user scripts to Special:Preferences
One of the problems that WP:US faces at the moment is that it isn't as widely known as maybe it ought to be, and that the method of installing scripts isn't intuitive and involves editing a personal scripts page, even if the user in question doesn't have an interest in developing scripts but only wanted to use them. Advances like {{subst:js}} are only so effective in this regard; but now, it seems that a better option is available. There is an extension mw:Extension:Gadgets that adds user scripts stored in MediaWiki: space as options in Special:Preferences; that way, we can have several users (probably mostly WP:US members, although there would be no reason to restrict the people who could check) check various scripts to see if they were safe to add as user preferences, and then an admin could edit MediaWiki space accordingly to add the script as a preference that users could easily access, install and uninstall, a sort of WP:US/S that's officially sanctioned by the software. Normally, this sort of project is the sort of thing that just gathers a bit of support on WP:VPR and then dies because nobody wants to implement it; however, the code has already been written, and reviewed by developers, and it is currently live on the German Wikipedia (if you have an account on dewiki, go to de:Special:Preferences and click on the rightmost tab to see the new code in action). This makes it seem much more likely that if their is community consensus, that extension will be installed. At the moment, I'm just posting this suggestion here, to see if people interested in user scripts think that this is a good idea; if the conversation here seems encouraging, I'll link it from VPR and we can have a proper attempt to gain consensus here to make a request to devs to enable this feature. Does anyone else think this is a good (or bad) idea? I'm trying to gauge consensus, so even a 'me too' is useful here if you agree. --ais523 14:39, 19 November 2007 (UTC)
- Strong support from me. Slightly better link: de:Special:Preferences?uselang=en. Relevant bugs: mediazilla:11956 (done for de.wp) and mediazilla:12020 (done for fr.wp). The only thing I don't like is that Gadget code is included after user code, which is kind of limits the flexibility for CSS gadgets ∴ AlexSm 16:54, 19 November 2007 (UTC)
[edit] Stub types script
Hi, I have a script installed (I'm pretty sure it was written by ais523) that easily allows me to add in a stub type simply by typing in the name of it. Anyway, what I would like to add to it (maybe I would only use it, or maybe it would be helpful to others) is a dropdown box with some stub types so that I don't have to keep typing the same ones in over and over. I can add in the types myself, I would just like to know how to add in the dropdown box. Thanks jj137 (Talk) 17:44, 23 November 2007 (UTC)
- Yes, I noticed you post this on WP:US/R. It's not very easy to do, though; the dialog box that appears can't be modified at all in code, so it would have to be done a different way. Should be possible, though. --ais523 17:46, 23 November 2007 (UTC)
[edit] Gadgets extension now live
It's now possible to add scripts to Special:Preferences (navigation popups is already there). I've started a new page at Wikipedia:WikiProject User scripts/Gadgets to try to decide which scripts should or should not be added (I know most about my own scripts, so they currently have some of the most detailed comments). Anyone who sees this, feel free to help reject/accept/test the scripts on the list! --ais523 09:20, 4 December 2007 (UTC)
[edit] Turn off scripts?
Is there an area an admin can edit other than monobook.js that prevents a user from using a particular script? I'm curious as I have suddenly and mysteriously lost all Twinkle functions without any kind of warning or reasoning (ie: no admin has told me and no changes have been made to the way my Firefox is setup that would prevent only 1 out of the several scripts I use from working). So, at the risk of offending admins, I want to know if this is possible and the admin that may have done this didn't tell me? -- ALLSTARecho 13:53, 20 December 2007 (UTC)
- Try going to your monobook and refreshing the page or purging. jj137 ♠ 20:43, 20 December 2007 (UTC)
- I've done that already but thanks. -- ALLSTARecho 21:59, 20 December 2007 (UTC)
- On some browsers, Twinkle is affected by a race condition in runOnloadHook() - see WT:TW for more information and a workaround. —Random832 18:40, 1 February 2008 (UTC)
- I've done that already but thanks. -- ALLSTARecho 21:59, 20 December 2007 (UTC)
[edit] Bot
Hi. I have created around 14,000 articles on wikipedia, higher than anybody, and am currently adding Frebnch communes at bot speed around 6 a minute and have requested that my new articles are automatically filtered but noone seems to be concerned. I have addressed this to several people but no one has taken it seriously when I said I was concerned about clogging up new pages even when I am adding general content. I refused adminship long ago but surely I am respected enough to be regarded as admin level in editing. I always add valuable content and most of my articles are referenced except such stubs. Isn't it time somebody made a decision to help new page patrollers by helping them. I;ve contributed tens times more than many adminstrators on wikipedia (107,000 edits) who automatically have their page unmarked -shouldn't mine be the same on a permanent basis? I consistenly add new content to wikipedia which is generally referenced and useful content. Deforestation in Brazil is what I am capable of. It would help patollers a lot. Any idea if you can help me receive permanent clearance? ♦ Sir Blofeld ♦ Talk? 23:00, 29 January 2008 (UTC)
- I'm not sure I get your point, Sir. Are you requesting that your edits be filtered/unfiltered? Are you running a bot or are you manually editing at "6 a minute"? Note, that this project is about client-side JavaScript, perhaps you should post your request at the bots page. Btw, having admin rights has little to do with the quality or quantity of your edits. Cheers, --Cameltrader (talk) 12:12, 30 January 2008 (UTC)
- You can request bot rights for an account (i.e. edits do not show on Recent Changes) for a specific task at WP:BRFA, whether you actually use a bot to do it or not. You should explain why the bot flag will be helpful, and create an alternate account to do the specific edits (because bot-flagged accounts should only be used for the purpose the flag was granted). By the way, administrator edits do show on Recent Changes, generally speaking; administrators can bot-flag rollbacks and the edits they roll back (this is rarely used, its main purpose is to prevent a Recent Changes flood attack) but no other sort of edit. --ais523 13:55, 1 February 2008 (UTC)
[edit] structured gadget pages
Halló! I created stuctured gadget pages via sections at s:yi: w:yi: wikt:yi:. During the first trials I used spaces in the sections. Then I could see that w:en: is using « - » while w:fr: does not. The clue is to define « MediaWiki:Gadget-section-foo-bar » . Maybe such examples should be illustrated.
btw: the structured gadget page at http://test.wikipedia.org/wiki/Special:Preferences is broken. Any clue why? Best regards
·לערי ריינהארט·T·m:Th·T·email me· 09:25, 12 February 2008 (UTC)
- I am not sure what you mean, but maybe Wikipedia:Gadget can help you. Сасусlе 02:04, 14 February 2008 (UTC)
[edit] Need help cleaning out my monobook.js
Would someone be willing to help me clean up monobook.js. I can't figure out what is what anymore. I don't know javascript, and I really didn't add things there neatly. I would like to use some of the tools made by others, but before I do, my monobook.js really needs to be cleaned up. Please? - LA @ 00:48, 25 February 2008 (UTC)
- The scripts that you're importing can be simplified to this:
importScript('User:Interiot/Tool2/code.js');
importScript('User:Splarka/dabfinder.js');
importScript('User:Pilaf/instaview.js');
- You have two scripts that aren't being imported, though (the null edit and template replace script). Cleaning those up will be harder. --ais523 14:44, 21 April 2008 (UTC)
[edit] watchlistSorter
I have just created a new watchlistSorter because the existing one no longer works. I think this could become an gadget candidate and I would like to hear your opinion to improve the script. See the script's page under User:Cacycle/watchlistSorter and the code under User:Cacycle/watchlistSorter.js. Сасусlе 05:45, 25 February 2008 (UTC)
[edit] Disappearing AfD tab?
Hi, could someone advise on my monobook page? It has been working fine with the extra tabs from Twinkle up until I got my extra admin buttons. Now there doesn't seem to be enough room at the top of the page and on many page views, the AfD tab is missing. It does appear on some pages (when not all the other tabs are present) and also on some other monitors I use; but on my home monitor (a small one set to 1024 x 768 pixels) the AfD tab is almost always missing. I'm a total beginner when it comes to all this business, so advice in words of one syllable, please! Kim Dent-Brown (Talk) 20:57, 27 February 2008 (UTC)
[edit] Smart quotes script
Attention all pedants, I made a script. smartQuotes.js replaces typewriter (ASCII) quotation marks with proper (Unicode) quotation marks ("smart quotes", see quotation mark glyphs) on any page you view. For example:
The Smashing Pumpkins’ Billy Corgan described Surfer Rosa as “the one that made me go, ‘holy shit’. It was so fresh. It rocked without being lame.”
The Smashing Pumpkins’ Billy Corgan described Surfer Rosa as “the one that made me go, ‘holy shit’. It was so fresh. It rocked without being lame.”
This script will not affect the editing window, so you won't need to worry about tainting your edits with odd glyphs. I know this is irrelevant to pretty much everyone (there is no difference whatsoever at small sizes if you're using Arial), but for the oddballs like me (who use serif fonts and aren't getting laid) it's available. If you're ever printing out a Wikipedia article for academic usage or something, you might consider applying this script for that extra professional touch.
I've only tested this in Firefox 2.0. It may or may not work in any other browsers.—Werson (talk) 03:48, 27 March 2008 (UTC)
[edit] "Replaced by addPortletLink" help
Hello. Recently, whenever I go to a page, I am greeted by a JavaScript alert which says: "Replaced by addPortletLink". Could someone help me with this problem? Thanks! archanamiya · talk 21:10, 4 April 2008 (UTC)
- See Wikipedia:Village pump (technical)#Strange error - "Replaced by addPortletLink()" --TheDJ (talk • contribs) 21:51, 4 April 2008 (UTC)
[edit] Link checker in JSON
I've extend the my checklinks script to output its results in JSON and created a reference JavaScript implementation. It also output the headers it retrieves, which could be useful for some scripts. — Dispenser 00:51, 20 April 2008 (UTC)
[edit] red link removal
I found that red link removal is cumbersome when dealing with more than three bad links in a very big section would someone make a script for me that would delete a bad link by hovering the mouse over the link.Hintss (talk)
[edit] Suggestion to avoid script incompatibility
I discovered a while back that scripts on Wikipedia have the rather annoying property that function names and global variables are shared between any scripts that run on the same page. This can often cause incompatibilities between scripts, such as where one script defines a global variable and another script uses a global variable of the same name as a user-defined setting; in such a case, the second script would use—and possibly change—the first script's value for the global variable, likely crashing one or both scripts. I ran into a version of this issue when one of my scripts stopped working after I installed another script, the reason being that they both had a function named loadXMLDoc.
What I suggest is that user scripts under this project include a global wrapper function around the script's functions and variables to avoid situations like this. Doing so would make the script's contents local to that one script and thus protected from unintentional access by another script.
To give an example, if there was a script named foo.js, it might look like this:
if ( typeof ( FooScriptVariable ) === 'undefined' ) { var FooScriptVariable = 'default value'; } function FooScript () { var foo = FooScriptVariable; function bar (baz) { // some code here } function spam () { // more code } addOnloadHook(spam); } FooScript();
The nice thing about this construction is that only FooScriptVariable and FooScript are in the global scope, but variable names inside the FooScript function can be as common or short as you want to make them; it eliminates the need to ensure that there are no naming conflicts. For a more detailed example of a script structured like this, see recent versions of User:Pyrospirit/metadata.js, which I just rewrote using this method.
So, does this seem like a good idea for more frequent use, or is there something that I've missed or doesn't work the way I think it does? This might be a good way of making Wikipedia script structure more standardized as well. Pyrospirit (talk · contribs) 02:07, 5 June 2008 (UTC)
- You could save one global object by using an anonymous function:
(function(){ var foo = FooScriptVariable; function bar (baz) { // some code here } function spam () { // more code } addOnloadHook(spam); })();
- Or you could enclose everything in an object, and again take only one global:
var FooScript = { foo : 'default value', bar : function (baz) { // some code here }, spam : function () { // more code } }; if ( typeof ( FooScriptVariable ) != 'undefined' ) { FooScript.foo = 'default value'; // Alternatively, if you can move the setting of "FooScriptVariable" to after // the include of this script, you could just set FooScript.foo directly. } if(doneOnloadHook) FooScript.spam(); else addOnloadHook(FooScript.spam);
-
- That's an interesting idea. However, I'm not sure it would be necessary to minimize globals that much; the idea is just to avoid spamming up the global namespace and to allow variables inside a script to have simple, common names such as
colorortext. Your suggestion does look like it would work as an alternative, though. Pyrospirit (talk · contribs) 00:40, 6 June 2008 (UTC)
- That's an interesting idea. However, I'm not sure it would be necessary to minimize globals that much; the idea is just to avoid spamming up the global namespace and to allow variables inside a script to have simple, common names such as
[edit] Script suggestion
I've got an idea for a script, maybe someone could work on it - basically what it does is allows you to right click on a (user/wikipedia/article) talk page section and it adds a link-to-that-section to a user subpage of your choosing, to remind you to return to threads you're need to check back on. Whaddyathink? –xeno (talk) 13:17, 16 July 2008 (UTC)
[edit] Query.php alert
Brion sentenced query.php to die on 25 August. Please make sure that your scripts are migrated to api.php! I'm especially worried about popups, which is largely unsupported and uses query.php in million places. MaxSem(Han shot first!) 07:07, 31 July 2008 (UTC)
[edit] Assessment scipt
Is there an existing script in assessing song-related and album-related articles. --Efe (talk) 05:30, 1 August 2008 (UTC)
[edit] How do I Activate this script
How do I use this JS?
/* * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message * Digest Algorithm, as defined in RFC 1321. * Version 2.2-alpha Copyright (C) Paul Johnston 1999 - 2005 * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet * Distributed under the BSD License * See http://pajhome.org.uk/crypt/md5 for more info. */ /* * Configurable variables. You may need to tweak these to be compatible with * the server-side, but the defaults work in most cases. */ var hexcase = 0; /* hex output format. 0 - lowercase; 1 - uppercase */ var b64pad = ""; /* base-64 pad character. "=" for strict RFC compliance */ /* * These are the functions you'll usually want to call * They take string arguments and return either hex or base-64 encoded strings */ function hex_md5(s) { return rstr2hex(rstr_md5(str2rstr_utf8(s))); } function b64_md5(s) { return rstr2b64(rstr_md5(str2rstr_utf8(s))); } function any_md5(s, e) { return rstr2any(rstr_md5(str2rstr_utf8(s)), e); } function hex_hmac_md5(k, d) { return rstr2hex(rstr_hmac_md5(str2rstr_utf8(k), str2rstr_utf8(d))); } function b64_hmac_md5(k, d) { return rstr2b64(rstr_hmac_md5(str2rstr_utf8(k), str2rstr_utf8(d))); } function any_hmac_md5(k, d, e) { return rstr2any(rstr_hmac_md5(str2rstr_utf8(k), str2rstr_utf8(d)), e); } /* * Perform a simple self-test to see if the VM is working */ function md5_vm_test() { return hex_md5("abc") == "900150983cd24fb0d6963f7d28e17f72"; } /* * Calculate the MD5 of a raw string */ function rstr_md5(s) { return binl2rstr(binl_md5(rstr2binl(s), s.length * 8)); } /* * Calculate the HMAC-MD5, of a key and some data (raw strings) */ function rstr_hmac_md5(key, data) { var bkey = rstr2binl(key); if(bkey.length > 16) bkey = binl_md5(bkey, key.length * 8); var ipad = Array(16), opad = Array(16); for(var i = 0; i < 16; i++) { ipad[i] = bkey[i] ^ 0x36363636; opad[i] = bkey[i] ^ 0x5C5C5C5C; } var hash = binl_md5(ipad.concat(rstr2binl(data)), 512 + data.length * 8); return binl2rstr(binl_md5(opad.concat(hash), 512 + 128)); } /* * Convert a raw string to a hex string */ function rstr2hex(input) { var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef"; var output = ""; var x; for(var i = 0; i < input.length; i++) { x = input.charCodeAt(i); output += hex_tab.charAt((x >>> 4) & 0x0F) + hex_tab.charAt( x & 0x0F); } return output; } /* * Convert a raw string to a base-64 string */ function rstr2b64(input) { var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; var output = ""; var len = input.length; for(var i = 0; i < len; i += 3) { var triplet = (input.charCodeAt(i) << 16) | (i + 1 < len ? input.charCodeAt(i+1) << 8 : 0) | (i + 2 < len ? input.charCodeAt(i+2) : 0); for(var j = 0; j < 4; j++) { if(i * 8 + j * 6 > input.length * 8) output += b64pad; else output += tab.charAt((triplet >>> 6*(3-j)) & 0x3F); } } return output; } /* * Convert a raw string to an arbitrary string encoding */ function rstr2any(input, encoding) { var divisor = encoding.length; var remainders = Array(); var i, q, x, quotient; /* Convert to an array of 16-bit big-endian values, forming the dividend */ var dividend = Array(input.length / 2); for(i = 0; i < dividend.length; i++) { dividend[i] = (input.charCodeAt(i * 2) << 8) | input.charCodeAt(i * 2 + 1); } /* * Repeatedly perform a long division. The binary array forms the dividend, * the length of the encoding is the divisor. Once computed, the quotient * forms the dividend for the next step. We stop when the dividend is zero. * All remainders are stored for later use. */ while(dividend.length > 0) { quotient = Array(); x = 0; for(i = 0; i < dividend.length; i++) { x = (x << 16) + dividend[i]; q = Math.floor(x / divisor); x -= q * divisor; if(quotient.length > 0 || q > 0) quotient[quotient.length] = q; } remainders[remainders.length] = x; dividend = quotient; } /* Convert the remainders to the output string */ var output = ""; for(i = remainders.length - 1; i >= 0; i--) output += encoding.charAt(remainders[i]); return output; } /* * Encode a string as utf-8. * For efficiency, this assumes the input is valid utf-16. */ function str2rstr_utf8(input) { var output = ""; var i = -1; var x, y; while(++i < input.length) { /* Decode utf-16 surrogate pairs */ x = input.charCodeAt(i); y = i + 1 < input.length ? input.charCodeAt(i + 1) : 0; if(0xD800 <= x && x <= 0xDBFF && 0xDC00 <= y && y <= 0xDFFF) { x = 0x10000 + ((x & 0x03FF) << 10) + (y & 0x03FF); i++; } /* Encode output as utf-8 */ if(x <= 0x7F) output += String.fromCharCode(x); else if(x <= 0x7FF) output += String.fromCharCode(0xC0 | ((x >>> 6 ) & 0x1F), 0x80 | ( x & 0x3F)); else if(x <= 0xFFFF) output += String.fromCharCode(0xE0 | ((x >>> 12) & 0x0F), 0x80 | ((x >>> 6 ) & 0x3F), 0x80 | ( x & 0x3F)); else if(x <= 0x1FFFFF) output += String.fromCharCode(0xF0 | ((x >>> 18) & 0x07), 0x80 | ((x >>> 12) & 0x3F), 0x80 | ((x >>> 6 ) & 0x3F), 0x80 | ( x & 0x3F)); } return output; } /* * Encode a string as utf-16 */ function str2rstr_utf16le(input) { var output = ""; for(var i = 0; i < input.length; i++) output += String.fromCharCode( input.charCodeAt(i) & 0xFF, (input.charCodeAt(i) >>> 8) & 0xFF); return output; } function str2rstr_utf16be(input) { var output = ""; for(var i = 0; i < input.length; i++) output += String.fromCharCode((input.charCodeAt(i) >>> 8) & 0xFF, input.charCodeAt(i) & 0xFF); return output; } /* * Convert a raw string to an array of little-endian words * Characters >255 have their high-byte silently ignored. */ function rstr2binl(input) { var output = Array(input.length >> 2); for(var i = 0; i < output.length; i++) output[i] = 0; for(var i = 0; i < input.length * 8; i += 8) output[i>>5] |= (input.charCodeAt(i / 8) & 0xFF) << (i%32); return output; } /* * Convert an array of little-endian words to a string */ function binl2rstr(input) { var output = ""; for(var i = 0; i < input.length * 32; i += 8) output += String.fromCharCode((input[i>>5] >>> (i % 32)) & 0xFF); return output; } /* * Calculate the MD5 of an array of little-endian words, and a bit length. */ function binl_md5(x, len) { /* append padding */ x[len >> 5] |= 0x80 << ((len) % 32); x[(((len + 64) >>> 9) << 4) + 14] = len; var a = 1732584193; var b = -271733879; var c = -1732584194; var d = 271733878; for(var i = 0; i < x.length; i += 16) { var olda = a; var oldb = b; var oldc = c; var oldd = d; a = md5_ff(a, b, c, d, x[i+ 0], 7 , -680876936); d = md5_ff(d, a, b, c, x[i+ 1], 12, -389564586); c = md5_ff(c, d, a, b, x[i+ 2], 17, 606105819); b = md5_ff(b, c, d, a, x[i+ 3], 22, -1044525330); a = md5_ff(a, b, c, d, x[i+ 4], 7 , -176418897); d = md5_ff(d, a, b, c, x[i+ 5], 12, 1200080426); c = md5_ff(c, d, a, b, x[i+ 6], 17, -1473231341); b = md5_ff(b, c, d, a, x[i+ 7], 22, -45705983); a = md5_ff(a, b, c, d, x[i+ 8], 7 , 1770035416); d = md5_ff(d, a, b, c, x[i+ 9], 12, -1958414417); c = md5_ff(c, d, a, b, x[i+10], 17, -42063); b = md5_ff(b, c, d, a, x[i+11], 22, -1990404162); a = md5_ff(a, b, c, d, x[i+12], 7 , 1804603682); d = md5_ff(d, a, b, c, x[i+13], 12, -40341101); c = md5_ff(c, d, a, b, x[i+14], 17, -1502002290); b = md5_ff(b, c, d, a, x[i+15], 22, 1236535329); a = md5_gg(a, b, c, d, x[i+ 1], 5 , -165796510); d = md5_gg(d, a, b, c, x[i+ 6], 9 , -1069501632); c = md5_gg(c, d, a, b, x[i+11], 14, 643717713); b = md5_gg(b, c, d, a, x[i+ 0], 20, -373897302); a = md5_gg(a, b, c, d, x[i+ 5], 5 , -701558691); d = md5_gg(d, a, b, c, x[i+10], 9 , 38016083); c = md5_gg(c, d, a, b, x[i+15], 14, -660478335); b = md5_gg(b, c, d, a, x[i+ 4], 20, -405537848); a = md5_gg(a, b, c, d, x[i+ 9], 5 , 568446438); d = md5_gg(d, a, b, c, x[i+14], 9 , -1019803690); c = md5_gg(c, d, a, b, x[i+ 3], 14, -187363961); b = md5_gg(b, c, d, a, x[i+ 8], 20, 1163531501); a = md5_gg(a, b, c, d, x[i+13], 5 , -1444681467); d = md5_gg(d, a, b, c, x[i+ 2], 9 , -51403784); c = md5_gg(c, d, a, b, x[i+ 7], 14, 1735328473); b = md5_gg(b, c, d, a, x[i+12], 20, -1926607734); a = md5_hh(a, b, c, d, x[i+ 5], 4 , -378558); d = md5_hh(d, a, b, c, x[i+ 8], 11, -2022574463); c = md5_hh(c, d, a, b, x[i+11], 16, 1839030562); b = md5_hh(b, c, d, a, x[i+14], 23, -35309556); a = md5_hh(a, b, c, d, x[i+ 1], 4 , -1530992060); d = md5_hh(d, a, b, c, x[i+ 4], 11, 1272893353); c = md5_hh(c, d, a, b, x[i+ 7], 16, -155497632); b = md5_hh(b, c, d, a, x[i+10], 23, -1094730640); a = md5_hh(a, b, c, d, x[i+13], 4 , 681279174); d = md5_hh(d, a, b, c, x[i+ 0], 11, -358537222); c = md5_hh(c, d, a, b, x[i+ 3], 16, -722521979); b = md5_hh(b, c, d, a, x[i+ 6], 23, 76029189); a = md5_hh(a, b, c, d, x[i+ 9], 4 , -640364487); d = md5_hh(d, a, b, c, x[i+12], 11, -421815835); c = md5_hh(c, d, a, b, x[i+15], 16, 530742520); b = md5_hh(b, c, d, a, x[i+ 2], 23, -995338651); a = md5_ii(a, b, c, d, x[i+ 0], 6 , -198630844); d = md5_ii(d, a, b, c, x[i+ 7], 10, 1126891415); c = md5_ii(c, d, a, b, x[i+14], 15, -1416354905); b = md5_ii(b, c, d, a, x[i+ 5], 21, -57434055); a = md5_ii(a, b, c, d, x[i+12], 6 , 1700485571); d = md5_ii(d, a, b, c, x[i+ 3], 10, -1894986606); c = md5_ii(c, d, a, b, x[i+10], 15, -1051523); b = md5_ii(b, c, d, a, x[i+ 1], 21, -2054922799); a = md5_ii(a, b, c, d, x[i+ 8], 6 , 1873313359); d = md5_ii(d, a, b, c, x[i+15], 10, -30611744); c = md5_ii(c, d, a, b, x[i+ 6], 15, -1560198380); b = md5_ii(b, c, d, a, x[i+13], 21, 1309151649); a = md5_ii(a, b, c, d, x[i+ 4], 6 , -145523070); d = md5_ii(d, a, b, c, x[i+11], 10, -1120210379); c = md5_ii(c, d, a, b, x[i+ 2], 15, 718787259); b = md5_ii(b, c, d, a, x[i+ 9], 21, -343485551); a = safe_add(a, olda); b = safe_add(b, oldb); c = safe_add(c, oldc); d = safe_add(d, oldd); } return Array(a, b, c, d); } /* * These functions implement the four basic operations the algorithm uses. */ function md5_cmn(q, a, b, x, s, t) { return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s),b); } function md5_ff(a, b, c, d, x, s, t) { return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t); } function md5_gg(a, b, c, d, x, s, t) { return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t); } function md5_hh(a, b, c, d, x, s, t) { return md5_cmn(b ^ c ^ d, a, b, x, s, t); } function md5_ii(a, b, c, d, x, s, t) { return md5_cmn(c ^ (b | (~d)), a, b, x, s, t); } /* * Add integers, wrapping at 2^32. This uses 16-bit operations internally * to work around bugs in some JS interpreters. */ function safe_add(x, y) { var lsw = (x & 0xFFFF) + (y & 0xFFFF); var msw = (x >> 16) + (y >> 16) + (lsw >> 16); return (msw << 16) | (lsw & 0xFFFF); } /* * Bitwise rotate a 32-bit number to the left. */ function bit_rol(num, cnt) { return (num << cnt) | (num >>> (32 - cnt)); }
Thisisatest247 (talk) 21:27, 23 August 2008 (UTC)
- Place the script in your script page (change the title if you're not using the default MonoBook skin). You can then call any of its functions in any other script. For example, you'd use
hex_md5('secret_stuff')to convert the string "secret_stuff" to "80ef97f147cc7abec067e19f19ab21d1". —{admin} Pathoschild 04:28:01, 27 September 2008 (UTC)
[edit] Friendly / Twinkle
Hello. I recently translated friendly and twinkle into Romanian, but when the script wants to post the edit (for the both scripts), FireBug says:
form is null
if( !tagRe.exec( form.wpTextbox1.value ) ) {
The scripts are here: ro:User:Firilacroco/friendly.js and ro:User:Firilacroco/twinkle.js, but I think that the problem isn't here ... it's somewhere else. I installed this script on Wikia and it work fine.
Thank you in advance. Daniel Message 11:09, 19 September 2008 (UTC)
[edit] Script documentation
I am currently trying two different ways of documenting user scripts. I would like feedback from the rest of you what you think about the two different approaches:
- The simple and compact approach, both code and documentation in the same page: User:Davidgothberg/newmessageshistory.js. Easy to use for the script programmer and has the advantage that if a user copies and pastes a script instead of importing it, then the documentation comes along. And perhaps easy to understand for the users too since it only involves a single page address to keep track of.
- The pimped up approach with a green /doc box like we do for template documentation: User:Davidgothberg/clock. Involves a total of three pages. Means more work for the script programmer to make. But this looks neat and most of all means that anyone can edit the documentation even though the script itself is on a protected page.
So what do you guys think?
--David Göthberg (talk) 14:37, 21 September 2008 (UTC)
-
- I never even considered your "compact" approach: the inability to use links, images, bold text etc. outweights everything else for me.
- I used to put documentation on the top of .js talk page like this:
=Documentation= ... =Discussion=, and I still might use this for very simple little scripts; cannot use interwikis though. - Now I prefer creating a separate page (like in user:js/watchlist): main page is /scriptname, while the code stays in /scriptname.js and should have the 1st line
//See [[user:me/scriptname]], solving the code copy-paste problem. Hmm, now that I think of it, it should probably say//See http://en.wikipedia.org/user:me/scriptname.
- Other comments. I don't see why you need another /doc subpage. I also don't think it's a good idea to push the .js part to the reader, both on the User:Davidgothberg/clock and on the Wikipedia:WikiProject User scripts/Scripts: I imagine most users are interested in the script description, and only a few might want to look at the actual code. —AlexSm 14:31, 22 September 2008 (UTC)
-
- AlexSm: Yes, now that I had some days to think about this I agree. Your analysis is spot on in all aspects. I will probably change to the way you describe to document my scripts. (And I see that many other scripts already use that way.)
- And a small correction, the link in the source should be
//See http://en.wikipedia.org/wiki/User:Me/scriptname. That is, don't forget the/wiki/part, or the user gets an ugly error message. And nice idea to use the full URL. Since then the link works even if the script has been copied and pasted to other projects like other language Wikipedias or even other sites. - Thanks for your input!
- --David Göthberg (talk) 17:11, 23 September 2008 (UTC)
[edit] AJAX framework
Hello. I created the AJAX framework to make AJAX programming effortless, and expanded the WikiProject's AJAX guide. (You can compare programming with and without the framework by looking at "Edit a page and other common actions" in the guide.) If you have suggestions for more functions, please post them here. —{admin} Pathoschild 04:20:05, 27 September 2008 (UTC)
[edit] Canonical namespace change coming: Image: -> File:
Brion has just announced on the wikitech-l list that he's planning to (finally) change the canonical name of the "Image:" namespace to "File:". This will affect any scripts that check for wgCanonicalNamespace == "Image", and will probably also affect scripts that make an equivalent check in other ways (such as by looking at wgTitle, location.href or the document title).
The recommended fix is to test for wgNamespaceNumber == 6, which will work both before and after the change. Please note that, if everything goes as planned, we'll only have about one week to fix our scripts before the change goes live.
More details at bugzilla:44. —Ilmari Karonen (talk) 02:35, 7 October 2008 (UTC)
[edit] Popup translations done in end999's monobook.js
I managed to do an ajax call to google's translation api. So I have popup translations for 23 languages on my monobook.js file: User:Endo999/monobook.js
It functions much like the google toolbar translation feature. You position the cursor over a word for a second or two and the foreign language translation pops up. You move the cursor away and the popup goes away. 23 languages supported right now.
Because my login does not survive going to, say, pt.wikipedia.org (the Portuguese wikipedia) I cannot surf into other language wikipedias and keep my login (and thus the monobook.js file). It would be good if I could do this, as I could read foreign language wikipedias this way.
I am a monoglot English speaker trying to extend my intermediate French and Spanish reading abilities, and I find the tool to be quite helpful in this regard, as I can read whole articles in Spanish and French without having to lookup a dictionary. The Google toolbar does not translate from French to English (only English to French) except for whole pages.
Endo999 (talk) 21:27, 15 October 2008 (UTC)
- 1: Wow, that seems like a very useful script!
- 2: Take a look at Help:Unified login. Nowadays you actually can stay logged in when you jump between different Wikimedia projects. I see that you have an account at the Spanish Wikipedia too. When you unify your accounts that account will be merged into your global account. (Provided that it is your account so you have the password for it.) And then you will automatically have an account on all the Mediawiki projects.
- 3: Even if you unify your account you still need to copy the script to your /monobook.js file for each project you want to use it on. But at least you will only have to log in to one project to be logged in everywhere.
- 4: You can take it one step further, but that is a bit tricky. You can put a short line of code in your /monobook.js at each project you frequent, and that line of code can load a javascript file from a central javascript file at your main account or from your own computer. That means if you update your central script you will automagically have your new functionality on all the projects that you frequent. You can read a little about that at Wikipedia:WikiProject User scripts/Guide. That page tells how to load from your own computer, but not how to load from a central script page on one Wikipedia from another language Wikipedia. So I just added it to my humongous to-do list that I should add such instructions to that page. You can also load CSS files from central locations or your own computer in a similar manner. That page also tells about that.
- --David Göthberg (talk) 10:56, 16 October 2008 (UTC)
-
- Regarding your last point, you can create a global script file at your name/global.js and include this line in your script files on other wikis:
-
importScriptURI('http://en.wikipedia.org/w/index.php?title=User:Your_name/global.js&action=raw&ctype=text/javascript');
- I'm writing a script that uses AJAX to configure each wiki (user pages and preferences), so I'll add script file creation.
- —{admin} Pathoschild 16:56:07, 16 October 2008 (UTC)
-
-
- Pathoschild: Yes, your code above seems right.
- And the script you are working on sounds complex, must be a lot of coding to get that one to work right.
- --David Göthberg (talk) 18:17, 16 October 2008 (UTC)
-
[edit] addOnloadHook
Hey, I'm fairly new to Wikipedia, and I just have one small question about userscripts. Does anyone know when the addOnloadHook() event executes? Is is onload or onDOMContentLoaded, or some other contrivance?
- lucideer 04:44, 16 November 2008 (UTC)
-
- View a page source, at the bottom of every page is:
-
<script type="text/javascript">if (window.runOnloadHook) runOnloadHook();</script>
- This iterates over and runs all functions that have been
addOnloadHook()'d. If this has already been run,addOnloadHook()'d functions run immediately. See wikibits.js, notably: "function addOnloadHook" and "function runOnloadHook". --Splarka (rant) 08:17, 16 November 2008 (UTC)
-
-
- Thank you. Nice and informative - lucideer 13:35, 17 November 2008 (UTC)
-
[edit] Who's using my script?
Having, newly posted a script for others to use, I don't suppose there's any way to tell what level of use it's getting, is there? —Largo Plazo (talk) 12:35, 17 November 2008 (UTC)
- You can check "What links here" from your script as it is common for people to include the script's wikilink in a comment before it is imported. Of course, there are many caveats to that. Mark Hurd (talk) 14:03, 1 April 2009 (UTC)
- The new search is actually quite good for this type of thing now, see for example my sysopdectector.js usage. --Splarka (rant) 07:20, 2 April 2009 (UTC)
[edit] Split-screen edit preview
I just wrote a gadget to load the preview in a resizable panel on the right-hand side of the screen. It's available by adding importScript('User:Bradv/splitpreview.js'); to your monobook.js or modern.js file. I'd like to get some people to test it and let me know what they think. Thanks. —BradV 21:09, 5 December 2008 (UTC)
[edit] Rollback scripts?
I've been trying to find some scripts that I can use for other wikis that would provide me with a rollback button (as I am only a rollbacker here). I've tried out numerous scripts on meta, from godmode-light to twinkle, and none have worked. Anybody know a functional script I could use? Inferno, Lord of Penguins 02:11, 7 February 2009 (UTC)
[edit] Batch Edits?
I'm looking for a way to edit many pages at once without opening each in a new browser tab. Is there a user script to edit pages in a batch? Submit a list of page names and a list of all edit textareas for the pages opens with one save button. No need to load the toolbar for each. --Subfader (talk) 16:52, 3 March 2009 (UTC)
- Hrm, well the first question would be; what exactly are you planning on editing en masse like this? AutoWikiBrowser is probably what you're looking for, but we generally don't grant approval to accounts with fewer than 500 mainspace edits. –xeno (talk) 16:56, 3 March 2009 (UTC)
- E.g. you are in a category and realize you should edit / add a sortkey to a bunch of pages. AWB would be too much and not suiteable. In some cases I prefer seeing all to-be-edited pages in edit mode on one page and save the bunch once. Since it are individual edits nontheless a global text replace won't help. --Subfader (talk) 17:04, 3 March 2009 (UTC)
[edit] Snippet Manager Script
I wrote a snippet manager script, for holding complex signatures, templates, or just plain pieces of text. Works with wikiEd (and TW/HW)
Link: User:Odie5533/SnipManager.js
Features:
- Customizable menu (smMenus)
- Customizable forms (smForms)
- Customizable form display (smColumns & smTextWidth)
- Form tooltips support
- Default value support (using either 'default':'default value here' or 'defeval' which supports javascript functions like getting the date)
- Prepend and append support (for adding <ref> tags)
- Multiple forms open at once
Upcoming features:
- ✓ Done 1-click insertion
- ✓ Done Drop-down menu support
--Odie5533 (talk) 05:58, 13 March 2009 (UTC)
I just updated the script to include full drop-down menu support. I've added a handful of templates to it and you can either recommend some and I can add them or add them via the customization option in your monobook.js file. The buttons also support simple evaluations and the Show refs and Ref errors buttons are hooked into another script. --Odie5533 (talk) 16:05, 19 March 2009 (UTC)
I made a page with installation instructions at User:Odie5533/SnipManager. --Odie5533 (talk) 17:26, 19 March 2009 (UTC)
[edit] Help!
I was recently informed that my new script, User:Drilnoth/assessortags.js (see documentation) works in practically no browsers other than Firefox 3. I'm still kind of new to scripting, so it would be much appreciated if someone could take a look at the code and see what the problem is... other scripts based on the MoreBits library work find in many browsers that this one just isn't showing up in. Please discuss this problem at User talk:Drilnoth/assessortags.js. Thank you! –Drilnoth (T • C) 16:13, 25 March 2009 (UTC)
- The errors I'm getting are all related to MoreBits xhr function (using Opera) - I've not explored it much, but I see it's using Mozilla's proprietary overrideMimeType() extension which isn't supported by other browsers. That might have something to do with it - you said other scripts using MoreBits work fine; are those working scripts making ajax requests? ɹəəpıɔnı 19:02, 25 March 2009 (UTC)
- Sorry... other scripts using morebits do not work fine in Internet Explorer... it's a browser issue. The problem actually isn't as bad as I thought; it's just IE and Opera which seem to be unable to run the script. WP:FURME also uses both morebits and AJAX. –Drilnoth (T • C) 20:01, 27 March 2009 (UTC)
- overrideMimeType() is a non-standard proprietary function introduced by Mozilla as a workaround because Firefox doesn't create responseXML for non-xml MIME-types. If I'm not mistaken this workaround is not necessary in Opera because Opera always creates responseXML for all MIME-types as far as I know. So just removing the non-standard function should give Opera compatibility. I'm not sure how IE deals with this though... ɹəəpıɔnı 18:41, 8 May 2009 (UTC)
- Sorry... other scripts using morebits do not work fine in Internet Explorer... it's a browser issue. The problem actually isn't as bad as I thought; it's just IE and Opera which seem to be unable to run the script. WP:FURME also uses both morebits and AJAX. –Drilnoth (T • C) 20:01, 27 March 2009 (UTC)
[edit] Capitalize First letter only
Hi, I'm looking for a user script that adds a new button to the toolbar to Capitalize The First Letters in marked text. I tested the wikEd editor (works fine, but too many other features and not as single button) and User:Zocky/Search Box (only lower or UPPER case). Any hints? Thanks. --Subfader (talk) 23:07, 26 April 2009 (UTC)
[edit] js not working
The answer to this is probably something really stupid, but since I added a new script to my monobook.js page, it's stopped working (not only is the new script having no effect, but the buttons I'd previously added have stopped appearing as well. I've refreshed the cache, logged out, restarted, everything I could think of, but still no luck. Any ideas?--Kotniski (talk) 08:34, 8 May 2009 (UTC)
- That should have fixed it. Didn't it? You refreshed your cache after that change?
If you have a look into your javascript console (Ctrl+Shift+J in Firefox) it should tell you where it has errors. Amalthea 09:29, 8 May 2009 (UTC)- Yes, I refreshed after that change and still don't get the effects. I'm using IE6 here - there is something called a Java Console, but it doesn't contain any information about errors.--Kotniski (talk) 09:43, 8 May 2009 (UTC)
- Ah, IE6. I seem to remember that IE has problems with commas at the end of lists and dictionaries, so I removed them from your monobook. Can you try again, please? Amalthea 09:49, 8 May 2009 (UTC)
- It worked!! That's brilliant, thanks! Would it make sense to make that code change in the instructions for downloading that script? (I mean, will it break anything in other browsers to do it that way?)--Kotniski (talk) 09:57, 8 May 2009 (UTC)
- Sure, go ahead, it won't break anything. Amalthea 10:10, 8 May 2009 (UTC)
- It worked!! That's brilliant, thanks! Would it make sense to make that code change in the instructions for downloading that script? (I mean, will it break anything in other browsers to do it that way?)--Kotniski (talk) 09:57, 8 May 2009 (UTC)
- Ah, IE6. I seem to remember that IE has problems with commas at the end of lists and dictionaries, so I removed them from your monobook. Can you try again, please? Amalthea 09:49, 8 May 2009 (UTC)
- Yes, I refreshed after that change and still don't get the effects. I'm using IE6 here - there is something called a Java Console, but it doesn't contain any information about errors.--Kotniski (talk) 09:43, 8 May 2009 (UTC)
[edit] Most Frequestly Used scripts section
would ^^that be possible? Kwiki (talk) 07:51, 10 May 2009 (UTC)
[edit] Please test my NICE interface modification
I've been working on a tool with some of my lab-mates. It makes a minor modification to the Wikipedia:UNDO interface. We are trying to do a proper study of it to see if it actually helps or not. If you would be willing to give it a try, you can find more information here.
If you have questions, suggestions or comments, please feel free to contact me. --EpochFail (talk|contribs) 18:50, 5 June 2009 (UTC)
[edit] wiki gold trophy article voting
how do you include the voting system in an article ? —Preceding unsigned comment added by 92.143.4.107 (talk) 15:10, 6 June 2009 (UTC)
[edit] JS on user page
This may be naive/stupid since I know next to nothing about actually implementing javascript, but I gotta ask - is there anything stopping me from writing a bar.js page and importing that into my user page only, for example? There are the obvious ethical reasons concerning malicious scripts and other visitors, but is there a technical reason it just doesn't happen? Again, sorry if this is dumb, just checking. ~ Amory (talk) 21:40, 6 June 2009 (UTC)
- There's nothing stopping you from creating a bar.js page, and using it for yourself, but it would never be executed (run) for anyone except yourself. All Javascripts that you want your account to run must be placed in your User:Yourusername/skinname.js file - this is usually monobook.js, as that is the (default) most common skin. Any Javascript in that file, or imported by that file, will be run on all pages for your account. It won't be run for anyone else, unless they also add the script to their page (you can't edit other user's .js files unless you are an administrator). Hope that answers your question. Ale_Jrbtalk 16:45, 7 June 2009 (UTC)
[edit] Are these only compatible with Wikipedia or can they be used with other Wikis too?
Can these be used with other wikis that are not part of the Wikimedia Foundation? Xhaoz Talk • Contribs 23:07, 27 June 2009 (UTC)
- It depends entirely on the script. Many would work by copying/pasting onto a user subpage on a different wiki and adding the appropriate importScript. Some, like wikiEd, work via Greasemonkey and can be set to work on any MediaWiki installation. Others are specific to Wikipedia installs. --Odie5533 (talk) 01:53, 28 June 2009 (UTC)
- And it also depends entirely on the Wiki. On the version of MediaWiki being used, what MW extensions are installed and what MW extensions are not installed that are on Wikipedia, many many variables. Trial and error is your only man. Try out a script, see if it works. Maybe ask the author for help tweaking it if it doesn't work at first. ɹəəpıɔnı 02:58, 28 June 2009 (UTC)
- Skins are also a factor; different skins use different IDs, HTML tags, etc. It also matters if the API is enabled on that specific wiki. If it isn't, you can pretty much forget about using, say, 30–40% of scripts that work here. As Lucideer said, trial and error is your only man. —Animum (talk) 00:03, 12 July 2009 (UTC)
- And it also depends entirely on the Wiki. On the version of MediaWiki being used, what MW extensions are installed and what MW extensions are not installed that are on Wikipedia, many many variables. Trial and error is your only man. Try out a script, see if it works. Maybe ask the author for help tweaking it if it doesn't work at first. ɹəəpıɔnı 02:58, 28 June 2009 (UTC)
[edit] Reword script
I made a script to make direct in-article edits of short phrases. A slightly better explanation can be found at User:M/Reword. Feedback would be appreciated, since I haven't tested it enough. Where should this script be added? I've also seen some errors where it seems that the scripts are being loaded out of order. How do I ensure correct loading order using importScript? M 23:30, 20 July 2009 (UTC)
[edit] Script working in areas
Would someone mind, please, figuring out how to get User:MarkS/extraeditbuttons.js working in other namespaces besides User and User talk? That's the only 2 places it will work currently. 09:01, 9 August 2009 (UTC)
[edit] Historical text highlighting wiki gadget
I'm sure many of you caught the news article about Adler and Alfaro's research in wiki trustability being applied to live Wikipedia. It just so happens that I have been working on a similar problem from a completely different direction during my research and am ready to share this work with the community. I have designed and implemented a user script modification that I call HAPPI and am currently running a non-profit/academic analysis of its usefulness. The script adds a couple of new controls that will appear over the edit pane. These controls will allow you to toggle the highlighting of wiki text while you edit it (like WikEd), but rather than syntax highlighting, HAPPI's highlighting gives you insight into how content has persisted through the history of the article. If you'd like to give it a try, please see the documentation page for more information. --EpochFail (talk|contribs) 17:51, 23 September 2009 (UTC)
[edit] How-to install user scripts page and maybe template needed
I think user script pages all need a friendly - for help installing user scripts please see ___ which sends them to a basic page on how users can install them. An example is here. Similar to the documentation for how to use a template. It seems basic to those writing these but I think may inspire more users to try using them. A template covering multiple issue may be best and could have a drop down list of all active scripts or even a link to a list of them as well as including many of the links on the project page. -- Banjeboi 23:17, 26 November 2009 (UTC)
- Yes, we can automatically add a link to a general script help page from the top of all .js and .css pages in user space. And that seems like good idea. Technically that link would be put in the MediaWiki:Clearyourcache system message.
- The help page should probably tell more than just how to install scripts. But I don't think it should list the available scripts, instead it should simply have a link to Wikipedia:WikiProject User scripts/Scripts which is the page for that.
- This project has some help pages, but I don't know if any of them fit as target for such a help link.
- And a related thing: We are just about to add automatic detection of script documentation pages, see the next section about that.
- --David Göthberg (talk) 15:02, 14 December 2009 (UTC)
[edit] Script documentation
We are about to deploy automatic detection of script documentation pages. All .js and .css pages will automatically show a box with a link to their doc page, if a doc page exists. See MediaWiki talk:Clearyourcache#Script documentation, {{script doc auto}} and Template talk:Script doc auto if you want to discuss this.
--David Göthberg (talk) 15:02, 14 December 2009 (UTC)
[edit] Script request?
I was wondering if it would be possible to write a script with the purpose of closing Requested move discussions. Could anyone familiar with that page let me know if it can be done? –Juliancolton | Talk 01:37, 17 January 2010 (UTC)
- Technically speaking, the correct place for this is Wikipedia:WikiProject_User_scripts/Requests. For the script, yes, it could be done. What exactly do you want it to do? Handle the actual moving, or just add the relevant templates on the talk page? Be specific! :D Ale_Jrbtalk 11:54, 17 January 2010 (UTC)
- Ah, didn't know that page exists. Oh well. :) I'd like it to be able to preform the move and take care of the talk page templates as well ideally. –Juliancolton | Talk 16:20, 17 January 2010 (UTC)
[edit] Deleted code won't go away
I have a clock on the corner of all pages similar to User:Davidgothberg/clock. Thing is, my monobook.js has been blank since August. I've purged it a few times and nothing's happened. It even shows up on other computers. I like having it there, but I want to change it slightly and can't figure out how it's showing up. What can I do to make it go away so I can replace it with the slightly modified clock I want? — User:ACupOfCoffee@ 18:55, 21 February 2010 (UTC)
- It's not there on my preferences page. Weird. — User:ACupOfCoffee@ 18:58, 21 February 2010 (UTC)
- Never mind. I see now that it's a gadget. — User:ACupOfCoffee@ 18:59, 21 February 2010 (UTC)
[edit] Smart quotes
Since the majority can’t be convinced to prefer typographic quotation marks in WP:MoS, I’m now using a slightly adapted version of User:Werson/smartQuotes.js to autoconvert straight quotes for display. Although it seems to work so far, perhaps someone can come up with a cleaner version. — Christoph Päper 21:28, 2 March 2010 (UTC)
[edit] Project tagging user script
Hi, I posted at Wikipedia:Bot_requests#Project_tagging_userscript about a project tagging user script; perhaps someone who knows about user scripts could respond there? Rd232 talk 16:48, 16 March 2010 (UTC)
[edit] Script purger for developers
I've created a script at User:Manishearth/purger, which allows developers to put the scripts that they want to test in "Purge mode", where the script will be forcibly fetched from the servers, bypassing the cache. This saves devs the time and bandwidth of bypassing their entire cache and re-downloading the Wikipedia scripts and CSS. ManishEarthTalk • Stalk 04:36, 24 March 2010 (UTC)
[edit] Menubook
I've created a new script that modifies the default Monobook skin by moving all of the navigation features to drop down menus at the top of the page. I'm looking for beta testers and for general feedback. You can check it out at User:Bradv/Scripts/Menubook. Brad 17:36, 17 April 2010 (UTC)
[edit] User:PleaseStand/prevnext.js
I have recently written the above script, which adds back-and-forth links to the top of each page similar to mw:Extension:Back-and-Forth, which is already used on at least one Wikipedia fork. It is based on User:PleaseStand/wikiapi.js, yet another API wrapper, which I hope I can eventually develop into a usable bot and user script framework. No problem with Firefox, but I doubt that it is compatible with Chrome because the order of an object's properties is not guaranteed, showing incorrect links if the current page does not exist. To me, this represents a serious shortcoming of the JSON output when used with a standard JSON parser or JavaScript interpreter. Is there any better way to fix this than alphabetically comparing the returned page titles to see which one is closer if the current page does not exist? Also, is it OK to combine the two queries, making use of allpages as both a generator and a list, and then encoding the URL on the client side? Of course, I could query allpages twice as a list and encode the URL client-side. I would like a second opinion to make sure I am not missing something. PleaseStand (talk) 23:06, 3 May 2010 (UTC)
- What query do you have in mind, for example? Amalthea 11:31, 6 May 2010 (UTC)
- The current queries are (changed from format=json to format=jsonfm so you can see the results):
- http://en.wikipedia.org/w/api.php?format=jsonfm&action=query&generator=allpages&gapnamespace=0&gapfrom=Coca-Cola&gapfilterredir=nonredirects&gaplimit=2&prop=info&inprop=url&maxage=600&gapdir=ascending
- http://en.wikipedia.org/w/api.php?format=jsonfm&action=query&generator=allpages&gapnamespace=0&gapfrom=Coca-Cola&gapfilterredir=nonredirects&gaplimit=2&prop=info&inprop=url&maxage=600&gapdir=descending
- The "one query" I am considering changing it to would be:
- The main disadvantages with the current queries are that two are required and I probably still need to add some code to get it to work correctly in Chrome (which would be needed even for the "one query"). Using gaplimit=1&aplimit=1 and the query-continue strings would not be an improvement because it would give incorrect results in all browsers for a non-existent page. PleaseStand (talk) 20:39, 6 May 2010 (UTC)
- Ah, now I see what you mean with the first part of your question. What you can do is add the additional parameter
&indexpageidsto your query (like this) which extends the JSON object by an ordered array of page ids that you can use to index the object. By the way, if possible you should avoid usingfor ... infor such iterations anyway since objects, even arrays, may get additional properties by some library or another, which can break your code if you don't account for it. Prototype does this, for example.
I haven't looked into optimizing your queries. Amalthea 15:27, 10 May 2010 (UTC)- OK, I have changed that. I am going to create a new code snippet to add to all my scripts so that I can do away with the for...in kludges; having a script User:PleaseStand/References segregator#What are its limitations? (as of now) fail when something is called
__proto__is not perfection. It's a shame that JavaScript does not support real associative arrays (including preservation of the order of insertion). PleaseStand (talk) 22:32, 10 May 2010 (UTC)
- OK, I have changed that. I am going to create a new code snippet to add to all my scripts so that I can do away with the for...in kludges; having a script User:PleaseStand/References segregator#What are its limitations? (as of now) fail when something is called
- Ah, now I see what you mean with the first part of your question. What you can do is add the additional parameter
- The current queries are (changed from format=json to format=jsonfm so you can see the results):
[edit] Fix delsort to work on Vector skin
Could an admin please fix Wikipedia:WikiProject Deletion sorting/delsort.js per User talk:John Vandenberg#Fix delsort to work on Vector skin before tomorrow's Vector rollout? PleaseStand (talk) 11:12, 12 May 2010 (UTC)
- Wow. I didn't realise that the rollout was so soon. I'll get right on it. John Vandenberg (chat) 11:48, 12 May 2010 (UTC)
[edit] Subpage search
Why does my script User:PleaseStand/Subpage search not work correctly with the new search box? It works perfectly when the button is clicked, but it doesn't when the return key is used. PleaseStand (talk) 02:20, 31 May 2010 (UTC)
- Pressing Return while having the suggestions open doesn't just submit the form anymore. Note that your script still works if you type something, then press Escape to get rid of the suggestions, and then press Return. Amalthea 09:13, 31 May 2010 (UTC)
- Is there a way my script can automatically turn off the suggestions when the box is checked since they are not needed? PleaseStand (talk) 16:07, 31 May 2010 (UTC)
[edit] Page Views
Excuse me if this is an easily answered question, but is there a script that allows one to add a "Page views" link to the toolbox section in the left sidebar? User:Dr pda/prosesizebytes.js adds a "Page size" link over there, so I know adding a link is possible, but I haven't been able to find any page view scripts from this WikiProject.. http://stats.grok.se/ shows page view statistics for any page on Wikipedia, so I was wondering if it was possible to tap into this system with a script. --Dudemanfellabra (talk) 20:56, 14 June 2010 (UTC)
- Even better would be a general purpose script that would add something to the sidebar, and allow a custom title and link that can take full or basepagename as an argument. –xenotalk 20:59, 14 June 2010 (UTC)
- Well, this link would be a little more complicated because it needs a month as well (i.e. June 2010 = 201006) to create a proper link. Just giving the page name wouldn't suffice. --Dudemanfellabra (talk) 21:01, 14 June 2010 (UTC)
// this adds a 'Page views' link to the toolbox bar addOnloadHook(function () { url = "http://stats.grok.se/en/201006/" + wgPageName; addPortletLink("p-tb", url, "Page views", "pt-logs"); });
You're on your own for getting the month to update dynamically ;p –xenotalk 21:05, 14 June 2010 (UTC)
- I figured out how to do it:
function PageViews() { var currentTime = new Date() var month = currentTime.getMonth() + 1 if (month<10) { month = "0" + month } var year = currentTime.getFullYear() url = "http://stats.grok.se/en/" + year + month + "/" + wgPageName; addPortletLink("p-tb", url, "Page views", "pt-logs"); } AddOnloadHook(PageViews); //Adds "Page views" to Toolbox section
- I didn't know it was that easy to get the page name haha. Thanks! --Dudemanfellabra (talk) 21:17, 14 June 2010 (UTC)
[edit] Extra Toolbar Buttons
I created a new script that adds strike, horizontal line, HTML comment, and math buttons to the enhanced editing toolbar. The script is here and the documentation is here. I was wondering if the project would find it useful. ~NerdyScienceDude (✉ • ✐) 19:02, 17 June 2010 (UTC)
- Might be a bit redundant to User:MarkS/Extra edit buttons. –xenotalk 19:05, 17 June 2010 (UTC)
- That script is for the old toolbar; this one is for the new enhanced one. This script adds the missing buttons the old editing toolbar had by default, with new icons. ~NerdyScienceDude (✉ • ✐) 19:11, 17 June 2010 (UTC)
- Pay no attention to the man behind the curtain! –xenotalk 19:12, 17 June 2010 (UTC)
- You can try it out if you want; the vector skin is not required. ~NerdyScienceDude (✉ • ✐) 19:18, 17 June 2010 (UTC)
- It looks like the script requires jQuery? Isn't that where the $j and .ready() comes from? Gary King (talk) 20:28, 17 June 2010 (UTC)
- Yes. Vector's scripts use jQuery as well. Amalthea 20:56, 17 June 2010 (UTC)
- So, I don't get why it would work outside the Vector skin if it requires jQuery, which seems to only be loaded in Vector? Gary King (talk) 21:12, 17 June 2010 (UTC)
- Ah, right, the extended toolbar is independent of Vector. It actually depends on your preferences whether you load jQuery. You get it if you use vector, but also if you turn on e.g. the extended toolbar or the live preview function.
Amalthea 21:19, 17 June 2010 (UTC)- (edit conflict) It should work just fine in Monobook if the enhanced editing toolbar is enabled; I just tested it. Enhanced editing toolbar scripts use jQuery. User:Mr.Z-man/refToolbar 2.0.js is another enhanced editing toolbar script that uses jQuery. ~NerdyScienceDude (✉ • ✐) 21:33, 17 June 2010 (UTC)
- Ah, right, the extended toolbar is independent of Vector. It actually depends on your preferences whether you load jQuery. You get it if you use vector, but also if you turn on e.g. the extended toolbar or the live preview function.
- So, I don't get why it would work outside the Vector skin if it requires jQuery, which seems to only be loaded in Vector? Gary King (talk) 21:12, 17 June 2010 (UTC)
- Yes. Vector's scripts use jQuery as well. Amalthea 20:56, 17 June 2010 (UTC)
- It looks like the script requires jQuery? Isn't that where the $j and .ready() comes from? Gary King (talk) 20:28, 17 June 2010 (UTC)
- You can try it out if you want; the vector skin is not required. ~NerdyScienceDude (✉ • ✐) 19:18, 17 June 2010 (UTC)
- Pay no attention to the man behind the curtain! –xenotalk 19:12, 17 June 2010 (UTC)
- That script is for the old toolbar; this one is for the new enhanced one. This script adds the missing buttons the old editing toolbar had by default, with new icons. ~NerdyScienceDude (✉ • ✐) 19:11, 17 June 2010 (UTC)
I just added blockquote and transclude buttons to the script. Any objections to adding it to the script page? If there aren't, I will add it. ~NerdyScienceDude (✉ • ✐) 00:45, 25 June 2010 (UTC)
Added since no major objections have been raised. In case anyone was wondering, the documentation for enhanced editing toolbar scripts can be found here. ~NerdyScienceDude (✉ • ✐) 17:11, 26 June 2010 (UTC)
On a side note, is enabling "Enable navigable table of contents" supposed to do anything? I don't see anything different in the edit page when enabling that and hard refreshing. Gary King (talk) 23:17, 17 June 2010 (UTC)
[edit] Reduce edit page clutter?
Is there a script which cleans up the disclaimer text and other junk on the Edit page? I know this is in the development pipeline for the usability update, Citron, but I figured someone might have cleaned up the page themselves. Thanks>> Ocaasi (talk) 03:39, 24 June 2010 (UTC)
[edit] Batch processor
Hello. Does JavaScript possess capabilities to implement batch processing of articles? I have interest is tasks such as: for all pages from given category follow the language interwiki and add there given new category (as in HotCat). Semi-automated processing would be especially useful. Incnis Mrsi (talk) 13:31, 20 June 2010 (UTC)
[edit] Here comes another toolbar script...
This one is more complex than the first one. It's EmoteToolbar, a script I just made. It adds an Emoticons section to the enhanced editing toolbar. Just like the other one, vector is not required to use it.
Does anyone think it would make a great addition to the user scripts page? ~NerdyScienceDude (✉ • ✐ • ✍) 20:56, 30 June 2010 (UTC)
- You can add it if you want, so that you share it with others. However, I think the general consensus is that people prefer to see fewer emoticons since they are distracting, add to page load times, etc. Gary King (talk · scripts) 22:03, 30 June 2010 (UTC)
- I like emoticons & smilies
fredgandt 03:39, 20 November 2011 (UTC)
- I like emoticons & smilies
[edit] Time between diffs
I just wrote User:Dudemanfellabra/diffs.js, using User:Gary King/minutes later for diff.js as a source. Gary King's script only works if the time between diffs is less than one hour, but my script will display the time out to days. It inserts a bolded, red span above the new diff containing the time. I've never written a script here before, so I don't really know where to add it or whatever I need to do with it. Thanks! --Dudemanfellabra (talk) 20:57, 2 July 2010 (UTC)
[edit] Editing pages with API
Hi. I think this section of the Techniques needs an update since now it can be done in much more elegant way using the API. I would also recommend importing to Wikipedia this wrapper. Editing a page with it is as simple as:
//initialise the API var api = JsMwApi("/w/api.php"); //get the page object var page = api.page("Wikipedia:Sandbox"); page.edit(function(text, save_function, res) { //process the wikitext of the page text = text + '|'; save_function( text, {summary: 'edit summary', minor: true}, function(res) { if(res && res.edit && res.edit.result && res.edit.result == 'Success') //saved successfully alert('Success'); else //handle the error alert('ERROR'); } ); });
No iframes, just GETs and POSTs. I think it could be useful to many script authors. Lampak (talk) 11:36, 6 August 2010 (UTC)
- That section in the guide seems pretty outdated. You can use Ajax to edit a page now; no iframe necessary. Gary King (talk · scripts) 17:21, 6 August 2010 (UTC)
[edit] Fork of Friendly
Hi, could someone help me? I need a fork for Esperanto Wikipedia of Friendly, but it should have a box in which type an argument. Then, the inserted template should be: {{Example|argument|date}} or also {{Example|temo = argument|dato = date}}. Could someone help me? Thank you! --→ Airon 09:45, 24 August 2010 (UTC)
[edit] jQuery and custom user scripts
I see that at least the vector skin loads jQuery, is it possible to write a custom script which uses jQuery functions? And if so which ones? Can I use $(document).ready? -- Eraserhead1 <talk> 22:56, 18 September 2010 (UTC)
- Monobook seems to use jQuery, too. I never noticed this. Is this new? Gary King (talk · scripts) 05:24, 19 September 2010 (UTC)
- jQuery is live at least since October (bugzilla:25419). Helder 20:10, 19 November 2010 (UTC) —Preceding unsigned comment added by Helder.wiki (talk • contribs)
- This query was made before October :) Gary King (talk · scripts) 01:45, 20 November 2010 (UTC)
- Good thing I checked back :). I'll give it another shot sometime. -- Eraserhead1 <talk> 20:43, 27 November 2010 (UTC)
- This query was made before October :) Gary King (talk · scripts) 01:45, 20 November 2010 (UTC)
- jQuery is live at least since October (bugzilla:25419). Helder 20:10, 19 November 2010 (UTC) —Preceding unsigned comment added by Helder.wiki (talk • contribs)
[edit] Discussion at Wikipedia talk:Spoiler may be of interest to scripters
At the moment there is an RFC at the spoiler guideline talk page that may be of interest to scripters because it's a proposal to make a small change to the layout of the Vector skin, probably to insert a link to the site Disclaimers into the sidebar so that it will be more prominent--currently it's only linked from the page bottom.
I expect that this would be achieved by having Mediawiki:Vector.js inject the link into the appropriate place. This may (or may not) have implications for scripts that make assumptions about the layout of the vector skin. --TS 23:07, 7 October 2010 (UTC)
[edit] Enhanced toolbar dialog help
On Wikisource I've been fiddling around with an attempt to make a script which automatically links pages in indices here. I've made a pared down copy of the link tool, the source of which can be found here. But it isn't appearing, and on closer inspection with webkit inspector, it has style="display: none" applied to it. I would guess that there's some sort of test suite which causes that on failure. Haven't been able to find anything about it though. Anyone know any more? Prosody (talk) 19:45, 19 November 2010 (UTC)
- Nevermind, I was looking at a way older version of jquery.wikiEditor.toolbar.js. Prosody (talk) 23:00, 19 November 2010 (UTC)
[edit] Still: How to use user script?
Could anyone explain it in the most simple way? I carefully read all relevant docs but still didn't get a clue.
Having a page 1: http://ru.wikipedia.org/wiki/Участник:Neolexx/MyCopyrightLawyer.js with a single code line window.alert('OK');
Having a page 2: http://ru.wikipedia.org/wiki/Участник:Neolexx/MyCopyrightLawyer
How to make the page 2 to display 'OK' message onload? NeoLexx (talk) 20:21, 27 November 2010 (UTC)
[edit]
If someone knowledgeable about how to work template coding could help fix the country demonym navbox generators, it would be greatly appreciated. At the moment, the existing country demonym navbox generators are Template:African topic, Template:Asian topic, Template:European topic, and Template:South American topic, but Template:North American topic and Template:Oceanian topic should be created as well. Template:Asian topic is currently up for deletion because it duplicates the functionality of Template:Asia topic even though that is not what it is supposed to do. The country demonym navbox generators are supposed to be the demonym counterparts of the country name navbox generators (ie. Template:Africa topic, Template:Asia topic, Template:North America topic, Template:South America topic, Template:Oceania topic, and Template:Africa topic). While the country name navbox generators create navboxes that create strings like "History of Canada" and "Culture of Iraq", the country demonym navbox generators are supposed to create navboxes that create strings like "Canadian literature" and "Iraqi cuisine". Nonetheless, the country demonym navbox generators have never worked because no one knowledgeable about the code has ever fixed them. If anyone would be willing to take on this task, it would be greatly appreciated. These navbox generators have the potential to make a substantial improvement to navigation between related articles on international topics. Neelix (talk) 16:01, 13 December 2010 (UTC)
[edit] Member activity
What is going here? Please remove members there are not anymore here in Wikipedia. Who response the script requests? --Perhelion (talk) 22:48, 3 January 2011 (UTC)
- Anyone can write any script they want - sometimes, helpful people will write scripts on behalf of people who post here. No one is obliged to either way. Ale_Jrbtalk 19:38, 4 January 2011 (UTC)
[edit] Regex problem
I wrote the script User:Jujutacular/closeFPC to close featured picture candidates. I'm currently having a problem with one my regular expressions. I'm using the code:
var regexTransclusion = new RegExp("{{"+closeFPC_PageName+"}}\n"); FPClist = FPClist.replace(regexTransclusion,'');
The code should remove the transclusion of the nomination from the list at WP:FPC. Normally the code works fine, but whenever the nomination page title includes parentheses, the code fails. Anyone know why this may be happening? (P.S. I'm not very experienced in scripts, so my apologies if this is a dumb question) Jujutacular talk 22:13, 4 January 2011 (UTC)
- Parentheses are used in JavaScript regexes to denote capturing groups. If you only need to replace the first occurrence of a text string case-sensitively (as your example seems to suggest), you could just use
FPClist.replace('{{' + closeFPC_PageName + '}}\n', '');If you need a case insensitive search, the ability to replace multiple instances of the substring, or something else regex offers, you could try the approach used by Lupin's tool (search forrecent2.processSysops =) or one that lists the specific characters to be escaped, and then set the appropriate flags ("g", "i", or "gi" as documented at MSDN). PleaseStand (talk) 00:24, 5 January 2011 (UTC)- Thank you, that works perfectly. Jujutacular talk 01:17, 5 January 2011 (UTC)
[edit] Firebug console doesn't work here - why?
Hello, I'm trying to start making a user script. To begin doing that, I'd like to try out some parts in the Firebug console. But anything I try, even alert("Hello");, has no effect. It works on other sites, but not here. What is Wikipedia doing to prevent Firebug from working, and how can I fix it?
Thanks! -- Ken_g6 (factors | composites) 23:26, 8 January 2011 (UTC)
- It works here. I just tested it. Gary King (talk · scripts) 23:40, 8 January 2011 (UTC)
- OK, I just disabled a bunch of add-ons and now it works. Now I gotta track down which one it was...(edit) and it's NoScript, even though all scripts are enabled. Time to file a bug or something. -- Ken_g6 (factors | composites) 06:29, 9 January 2011 (UTC)
- And resetting the settings fixed it. Thanks for the non-bug report! -- Ken_g6 (factors | composites) 06:47, 9 January 2011 (UTC)
[edit] [Wikitech-l] [ResourceLoader] JavaScript may break on your wiki: Fix it before that happens
Cross posting this from the mailing lists. the wub "?!" 10:16, 12 February 2011 (UTC)
Greetings, As you may know, the Wikimedia tech team has started to upgrade MediaWiki on some wikis. MediaWiki is the software that runs all Wikimedia wikis.
The most visible change for Wikimedia users will be the deployment of ResourceLoader.
ResourceLoader optimizes the use of JavaScript in MediaWiki, speeding up its delivery by compressing it sometimes, and cutting down on the amount of unused JavaScript that gets delivered to the browser in the first place. The installation of ResourceLoader may cause compatibility issues with existing JavaScript code.
Trevor Parscal and Roan Kattouw, the main developers of ResourceLoader, will be available on IRC on Monday, February 14th, at 18:00 (UTC) (all timezones), to answer questions and help fix issues related to ResourceLoader.
If you maintain JavaScript code on your home wiki, please attend. Don't wait until your wiki's JavaScript is all broken.
Please spread this information as widely as possible; it's critical to reach as many local JavaScript maintainers as possible.
Logs of the session will be published publicly.
-- Guillaume Paumier Product manager - Wikimedia Foundation
- Is this going to effect maintainers of gadgets? Are gadgets going to load correctly or do they have to be changed in order to continue loading?
- Is this going to effect vector.js javascript code? Is this code going to load correctly or do we have to change it in order to continue loading?
Endo999 (talk) 21:20, 12 February 2011 (UTC)
[edit] DOMParser problems
Continuing this discussion. When HTML 5 was enabled for 24 hours last week, all scripts using DOMParser to parse results returned by invoking index.php failed, to the best of my knowledge. HTML 5 is about to be re-enabled, which will kill everyone again. A massive rewrite of Twinkle is in progress. . AlexSm seems to have said that it's not really a problem. I don't understand this statement, so I'm posting here. All of my research shows that DOMParser is fundamentally incompatible with HTML 5. Furthermore, the Wikipedia developers have been telling everyone to use api.php exclusively for many years and their tolerance for non-compliance appears to be down to zero. Also, see my related post on JavaScript deprecations. —UncleDouggie (talk) 08:56, 1 March 2011 (UTC)
- This is the message that I had problems with. The thing is, using index.php ≠ using Dom Parser. Fetching the whole HTML page and then using Dom Parser was a problem, not using index.php per se. Thus switching to HTML5 will not automatically break all the scripts that make requests to index.php (WikEd comes to mind here). Some parameters (action=raw / action=render) can make index.php output specific data which doesn't even have the DOCTYPE. Having said that, I agree that it is much better to use API whenever possible and even the raw/render index.php parameters can now be replaced with API. — AlexSm 16:52, 1 March 2011 (UTC)
- As for XML statement, it was answered by Ale jrb. — AlexSm 16:52, 1 March 2011 (UTC)
- OK, but the vast majority of scripts that use index.php are retrieving and attempting to parse HTML. We need to make clear to users that this is all about to break, not give them false hope that their index.php code will somehow survive. I have referenced HTML in the majority of my comments, either directly, or in a preceding comment in the same section. —UncleDouggie (talk) 01:26, 2 March 2011 (UTC)
[edit] Replacing importScript()
importScript() has been deprecated in MediaWiki 1.17 and the developers have instructed us to transition to mw.loader.load(). I have tried this out for the Twinkle rewrite and it's been a disaster. I had to finally revert back to importScript(). I just want to save others the trouble of going down this painful road. Hopefully a lot of changes will be made before importScript() is removed. There are several related bug reports. My biggest issues are:
- It's impossible to debug scripts using Firefox/Firebug, even when setting debug=true to stop minification. Firebug isn't happy when scripts are appended to the body after the page is loaded as is done by mw.loader.load(). Opera can debug them, but it's very hard to select a particular script name and strange errors show up on the console.
- importScript() filters multiple requests for the same script, which are very common on en.wikipedia with all our various utility scripts. mw.loader.load() doesn't perform such filtering.
- mw.loader.load() will only minify registered modules and your top-level skin.js file. It won't minify user scripts. importScript() doesn't minify either, but the promise of minification was a big reason to consider switching to mw.loader.load().
- Loading a script that is in the browser cache takes twice as long with mw.loader.load() as it does with importScript(). It might be that the technique used by mw.loader.load() is somehow causing the cache to be bypassed.
- The god-awful syntax:
importScript('User:Foo/bar.js');gets replaced bymw.loader.load(mw.config.get('wgServer') + mw.config.get('wgScript') + '?title=User:Foo/bar.js&action=raw&ctype=text/javascript');- While I could actually live with this in Twinkle if the other things worked, requiring this for all uses of importScript() on the project shows an utter disregard for usability.
- The almost non-existent documentation. I had to figure all this out by myself, including debugging into the MediaWiki scripts. The documentation only covers use of registered modules. User scripts seem to have been an afterthought.
If you've been dreaming of using mw.loader.using() to solve dependency issues between user scripts, sorry. mw.loader.using() can only be used for dependencies on registered modules such as jquery.ui.dialog. I've now solved all the dependency problems in the new Twinkle, but I had to write my own loader to do it. —UncleDouggie (talk) 11:17, 3 April 2011 (UTC)
[edit] Request
Hi. A question from a newby. Is it possible to have a function to be executed by a button? E.g. convert selected text to Lowercase? I tried to look around but I could not find anything. If so, can you give a short example of code? Mpaa (talk) 23:00, 5 May 2011 (UTC)
- Hi. Short answer is "yes". You'll need code to add the button to the loaded page then add an event listener to the button then code to run when the button is pressed causing the event to trigger. Since I have no idea how much a newby you are I suggest looking at other scripts that do basically the same thing. I have one written in pure JavaScript (not jQuery or shorthand of any kind) that follows this process. See User:Fred Gandt/getUnpatrolledOfAlexNewArtBotResultsPages.js. It is only one example and some might argue that it's not a good one but it's better than nthing
fredgandt 03:34, 20 November 2011 (UTC)
[edit] FileRedirect
Hello, I'm from Polish Wikipedia. I've made a very short script that redirects user from en.wiki File's page to its commons page, when it's hosted there. If it's hosted locally it doesn't redirect. To use it You should copy that (yes, with the first line, please – I'd be glad if I could know how many ppl uses that script:>).
//if viewing page of a File then redirect to commons; script from [[User:Vinne2/FileRedirect.js]] importScript('User:Vinne2/FileRedirect.js')
Can You tell me where should I add information about that script? The structure of pages about script, tools and gadgets here is different from the one on pl.wiki, so I'm lost here. Vinne2 (talk) 15:24, 16 October 2011 (UTC)
[edit] Can anyone help...
I posted the following message to the Help Desk a day or two ago and I didn't get an answer. I was hoping maybe somebody here could help. Also, it would be preferable if you could respond on my talk page. Thanks.
- Hello, I've been starting to experiment with my skin .js pages and trying to modify other scripts for my own use (in my own userspace of course). During this process I keep on finding variables like wgScriptPath, #wpSummary, wgCanonicalNamespace, etc. While I've been able to figure out the basic meaning of those above, there are many others variables I can't find out about. These variables aren't defined anywhere in the script so my first guess was that they were MediaWiki global variables, or something like that. Can somebody please explain to me where I can find a listing and explanation of all these frequently occurring variables. Any help is very much appreciated, M Magister Scientatalk (20 November 2011)
-
-
- Ah yes that's probably more appropriate than the one below. This section is the right section. The note below about the namespace numbers still applies, though. I guess that page is fairly new (as in, less than five years or so), since I'm only familiar with the one below, which I probably last had to refer to a few years ago. I wish I had this new link to use as a reference back then, that's for sure. Also, this question that you posted at WP:HD is better suited for WP:VPT, so be sure to bookmark that or something for future reference when you need technical help. Gary King (talk · scripts) 03:24, 20 November 2011 (UTC)
-
-
- (edit conflict) This is probably the most appropriate page to explain this stuff. I know that it doesn't explicitly lay out what each variable means, but it shouldn't be too difficult to determine that. The example given there provides the information for that very page. Namespaces are unique to each wiki; the ones for Wikipedia are found here. If you have questions on specific variables, just ask here. Gary King (talk · scripts) 03:22, 20 November 2011 (UTC)
-
- Thanks both of you for all the information. Highly appreciated, M Magister Scientatalk (20 November 2011)