Wikipedia talk:User scripts/Techniques

From Wikipedia, the free encyclopedia
Jump to: navigation, search

Change links with ta[edit]

seems not to be working

addOnloadHook(function () {
 ta['ca-delete']=['','del'];
    ta['pt-mytalk']=['','talk'];
    akeytt();
}

changes nothing at all, whereas JesseW's tip works:

addOnloadHook(function () {
q=document.getElementById("pt-mytalk").firstChild; q.removeChild(q.firstChild); q.appendChild(document.createTextNode("talk")) 
}

works. Now, the ta[] way seems more flexible and short, why isn't it working? anyone has ideas? -- ( drini's page ) 01:17, 8 March 2006 (UTC)

They do seperate things. ta defines accesskeys and long tooltip descriptions, my tip defines URLs and displayed names. JesseW, the juggling janitor 01:52, 8 March 2006 (UTC)

import_external[edit]

I looked in the MediaWiki source, and the "dontcountme=s" bit does not seem to do anything. Experiments showed that it can safely be removed. -- Jitse Niesen (talk) 22:32, 20 March 2006 (UTC)

Any historical reason it's there? Shinobu 01:27, 13 December 2006 (UTC)
It may be used for some sort of backend log processing and not in the software itself. Mike Dillon 05:11, 24 February 2007 (UTC)

Editing the wikitext of a page - Need help[edit]

Hi. I try to use the provided javascript. It doesn't work both in latest version of IE and Firefox. It said no properties like it couldn't access document of the iframe or something. Can anyone help? Thanks --Jutiphan | Talk - 01:57, 24 February 2007 (UTC)

I had the same problem. It says "Error: uncaught exception: Permission denied to call method XMLHttpRequest.open". --Conquestofparadise 17:42, 19 August 2007 (UTC)
I just now tested the examples in "Editing the wikitext of a page" from the address bar in IE6 and Firefox (recently updated) and it worked flawlessly. Does it only happen in scriptfiles, or does it also fail when you use the examples in the address bar directly? It may be possible things were changed so it doesn't work anymore... that would mean trouble, because some browsers have AJAX disabled by default (and rightly so, actually). Shinobu 15:28, 14 November 2007 (UTC)

Other way of checking if a page is editable?[edit]

var wgRestrictionEdit = ["sysop"];
var wgUserGroups = ["*", "user", "autoconfirmed", "emailconfirmed"];

If any one of the items in the first list is present in the second list, you can edit a page, no? Shinobu 15:17, 14 November 2007 (UTC)

Well, pretty much like that I suppose, except for «Mediawiki:» namespace, user .js/.css files and cascaded protection (e.g. see Wikipedia:Selected anniversaries/November 14 while it's still on the main page). However cascaded protection is not indicated even by Mediawiki (the link is «edit this page», not «view source»).
By the way, ever since I noticed the addition of wgRestrictionEdit several months ago, I had this idea to implement the global Common.js "display protection level" script so admins could stop adding {{sprotected}} and {{protected}} to the pages. However from my experience I don't expect this proposal to succeed. P.S. Also see still not fixed mediazilla:10347AlexSm 18:55, 14 November 2007 (UTC)

Shoot. That means we do have to check for the presence of the edit tab. Does that cause problems in other skins? Shinobu 12:50, 15 November 2007 (UTC)

I just noticed... checking for the edit tab would be a bit like your checking for an [edit] link, but more reliable, and therefore perhaps this could be used in my edit top. Shinobu 12:59, 15 November 2007 (UTC)

Except when __NOEDITSECTION__ magic word is used, or when user set "no [edit] links" in preferences (doesn't matter for userscript but my version is also used in ru:MediaWiki:Common.js). And of course, there is also a correct name and a tolltip (respecting user language) ∴ AlexSm 21:38, 15 November 2007 (UTC)

I usually don't tip tollbooth operators, but to each his own. Anyway people with "no [edit] links" won't use edit top, so that's okay. __NOEDITSECTION__ isn't used much. Of course I've got no hard statistics about this, but I think that there are more pages with only one section than there are pages with __NOEDITSECTION__. So my mind is set - I'll check for the edit tab. Shinobu 09:21, 16 November 2007 (UTC)

Or I could first check for [edit]'s and only check for the edit tab if I can't find any. So much for "my mind is set" then. Shinobu (talk) 14:36, 17 November 2007 (UTC)

Page outdated[edit]

By the way, I believe this /Techniques page is really outdated, and not worth fixing. I'm still not sure what to do with it: "archiving" or renaming to "Old Techniques" or simply forgetting and starting a new page under /Guides... ∴ AlexSm 19:02, 14 November 2007 (UTC)

Me neither. Some seeds of good ideas here and there, but most of it... Still, some of the techniques here may have value. Perhaps quickly mark the outdated stuff, discuss a bit here and decide what to do then? Shinobu 12:48, 15 November 2007 (UTC)
It occurs to me that what you would expect to find here is a thorough explanation of all the wg* variables, wikibits functions etc. Shinobu 15:02, 15 November 2007 (UTC)
And what about dropping all those "sourcings" for the simple one-liners? It's not rocket science, after all. Shinobu 15:11, 15 November 2007 (UTC)

insertTags[edit]

You know, insertTags would suck a lot less if it had a way to use a callback function instead of just the sample text method. Shinobu 11:10, 16 November 2007 (UTC)

I've hacked up a script that does this and also misses a few bugs insertTags has; I'll add it in the scripts list. Shinobu (talk) 14:34, 17 November 2007 (UTC)

The current insertTags() version is kind of mine, so if you could elaborate a little about "a few bugs"... and User_talk:Gerbrant/edit/selection.js doesn't seem to offer enough explanation for me ∴ AlexSm 14:59, 17 November 2007 (UTC)

The most annoying thing I fixed was that the selection position was always wrong in Konqueror. There were one or two minor other things, but unfortunately the wikibits code has changed since I last downloaded it and I see that it misses at least one bug mine still has. A side-by-side comprison is thus not feasible and I don't have the time to sieve through it right now. Shinobu (talk) 17:15, 19 November 2007 (UTC)

importScriptURI x importScript[edit]

It is not clear for me when should I use importScript and when to use importScriptURI. Does anybody know what is the correct? Thanks ind advance... Helder (talk) 21:59, 16 April 2009 (UTC)

I found the answer! Helder (talk) 16:42, 1 May 2009 (UTC)