Wikipedia talk:User scripts/Archive 5
![]() | This is an archive of past discussions on Wikipedia:User scripts. Do not edit the contents of this page. If you wish to start a new discussion or revive an old one, please do so on the current talk page. |
Archive 1 | ← | Archive 3 | Archive 4 | Archive 5 | Archive 6 | Archive 7 |
Protection and management of scripts?
See discussion at Village Pump (policy)#Protection and management of scripts?. Relevant to Lua, userscripts, and user scripting generally. Comments appreciated.
FT2 (Talk | email) 02:06, 20 March 2013 (UTC)
Request to change User Tabs script
![]() | This edit request has been answered. Set the |answered= parameter to no to reactivate your request. |
Should someone change Wikipedia:WikiProject User scripts/Scripts/User tabs from http://toolserver.org/~tparis/count/index.php? to http://tools.wmflabs.org/xtools/pcount/index.php? as a result of the move? Thanks! GoingBatty (talk) 02:47, 3 June 2013 (UTC)
unofficial opt-in ad scripts?
It is my understanding that the Wikimedia Foundation's official stance is it will not run any ads. There have been some serious proposals for an opt-in ad system, but nothing has come out of it.
On the other hand, opt-in ads are something that can be easily implemented in a user script. For example, I could sign up for an ad exchange service (such as Infolinks) and put the ad-generating code in a script here. Any money that is gained can then be donated to Wikipedia.
However, there are a few potential problems with this approach. Because the Wikimedia Foundation does not officially run ads, there would be no oversight: a less-than-honest person could keep some of the funds for himself. Also, if a user does something that violates the ad exchange's terms of service, it could sever ties between the service and Wikipedia. This could become problematic should Wikipedia ever "needs" ads.
Would such a script be discouraged? --Ixfd64 (talk) 18:56, 4 July 2013 (UTC)
Adding tabs to the project page
Would anyone mind if I add a tab system to the project page that would look like the ones at the AfC project or the GoCE project? Thanks! (I really think it would look a lot better and aid in navigation.) APerson (talk!) 20:57, 11 August 2013 (UTC)
Done Added. APerson (talk!) 01:10, 12 August 2013 (UTC)
RfC: Are the Category:Wikipedians and its subcategories appropriate for Wikipedia
There is an ongoing RfC going on at Category talk:Wikipedians#RfC: Is this category and current subcategories appropriate for Wikipedia that readers of this WikiProject may be interested it. Technical 13 (talk) 12:19, 29 August 2013 (UTC)
No more javascript
I recently got a new laptop, and I don't get my javascript any more on no:Wikisource. (I neither get my additional edit buttons, nor the [common] box of edit tools under the edit window. Is there something wrong with my javascript or some plug-in/add-on that I don't have? V85 (talk) 04:21, 6 May 2013 (UTC)
- Have you changed the browser? Which browser you use, with which addons (Noscript?). --Rezonansowy --Rezonansowy (talk • contribs) 01:25, 9 November 2013 (UTC)
User:Rezonansowy/ToCommons
I'm not sure where should I place my script - User:Rezonansowy/ToCommons. --Rezonansowy (talk • contribs) 23:23, 9 November 2013 (UTC)
- I'd put it under "Images", I think. equazcion → 01:15, 10 Nov 2013 (UTC)
- Thanks! --Rezonansowy (talk • contribs) 12:31, 10 November 2013 (UTC)
BeeLine Reader
Have there been any significant efforts/discussions about adapting BeeLine Reader as a user script?
The issues with the existing implementation are as follows:
A quick look at the bookmarklet shows that it loads some scripts/stylesheets from www.beelinereader.com
without https. The Firefox extension seems to have that problem too.
HTTPS support?
|
---|
|
I could work around that by making on-wiki copies of the dependencies, except that I would like the script only to change text colors without doing any of the other reformatting it currently does. This is somewhat nontrivial for me to figure out, given the length of the script that does the actual work.
Any ideas where I should get started? --SoledadKabocha (talk) 22:01, 14 December 2013 (UTC)
- To clarify, it is possible that the "readability" script only does the aforementioned "reformatting," and the colors are handled elsewhere. --SoledadKabocha (talk) 03:16, 15 December 2013 (UTC)
- Upon digging a bit further, it is indeed the case that the coloring is handled separately from readability.js; the files have different names depending on the color scheme chosen (see the radio buttons on the bookmarklet installation page, and look at the resulting code of the bookmarklet). For example: BlackNavyCrimson.js for the "Dark" color scheme. An obvious change that would need to be made (in addition to removing the Google Analytics stuff) is that the
readInner
element ID would need to be changed tobodyContent
orcontent
if the page isn't going to be preprocessed by Readability. - At this point I think I can handle this myself. I don't intend for this to be developed as a gadget or otherwise widely publicized; that could run into licensing issues anyway. --SoledadKabocha (talk) 03:36, 15 December 2013 (UTC)
- Upon digging a bit further, it is indeed the case that the coloring is handled separately from readability.js; the files have different names depending on the color scheme chosen (see the radio buttons on the bookmarklet installation page, and look at the resulting code of the bookmarklet). For example: BlackNavyCrimson.js for the "Dark" color scheme. An obvious change that would need to be made (in addition to removing the Google Analytics stuff) is that the
JavaScript edit requests
See template talk:JavaScript where a new JS edit request template has been proposed -- 70.50.148.122 (talk) 07:01, 9 January 2014 (UTC)
Gadget or user script for disablesuggest
I have gone looking for admins who would like to approve a proposal I made for a gadget that disables search suggestions. Recently, one of them referred me to this project.
The project page says that the "most popular" scripts become gadgets. What usage is this approximately? The core preference to disable suggestions was used by 112 editors and some others couldn't find it. At least 7 of them have voiced their desire to get this option back in a discussion and a developer has encouraged me to write a similar gadget. The sheer number of search suggest bugs both technical and philosophical makes me surprised that the option would ever be taken out of core.
Are these reasons enough to have my script added as a gadget? If not, I am happy to list it on the project page so we can first make sure that it gets enough usage. I just hope this gets the attention of someone who can make the decision. Connor Behan (talk) 05:59, 6 February 2014 (UTC)
- Putting it in User:Connor_Behan/disablesuggest.js as this seems better than referring people to the proposal page. Check there for the latest version. Connor Behan (talk) 01:55, 7 February 2014 (UTC)
- Many thanks to TheDJ who just added this as a gadget! Connor Behan (talk) 20:36, 1 March 2014 (UTC)
Need script to filter navboxes in "What links here"
When using the tool "What links here" for geographical entries (such as Wichita Falls, Texas), all links in navboxes are listed as well as the usual article links. For someplace like Texas, this makes hundreds and hundreds of links to wade through. Would it be possible to make a user script that would filter out everything in navboxes? Or is there one already I haven't found? Many thanks. - Gorthian (talk) 19:39, 19 April 2014 (UTC)
- I think that would require the script to request and download all these hundreds of articles in order to check whether the link is in a template or not, not really a good idea. --V111P (talk) 08:48, 20 April 2014 (UTC)
- Not necessarily. You could prompt the user for the name of the navbox(es) that should be excluded (e.g. in this case {{Texas}} plus some others). Then you could query what links are inside that template and subtract those pages off from the whatlinkshere of the page. In navboxes, any link inside the template is also a link to that page.--Dudemanfellabra (talk) 17:03, 20 April 2014 (UTC)
- That wouldn't quite work, as many small cities in Texas have the template without being in the template (e.g. Hutchins, Texas). --V111P (talk) 13:43, 21 April 2014 (UTC)
- I was thinking something along the lines of an invisible something in the navbox template that would tell the script "here are the links contained within," and then the script could note those and ignore them. Obviously, I'm no programmer; I don't know how any of this works. - Gorthian (talk) 19:25, 21 April 2014 (UTC)
- No, I just used the template's "What links here" backlinks instead of the links in the template and it works! The former include all the pages that transclude the template. Thanks for the idea, Gorthian! I'll post the script a little later. --V111P (talk) 19:42, 21 April 2014 (UTC)
- Really? Cool! I'm thrilled! - Gorthian (talk) 02:16, 22 April 2014 (UTC)
- I want to thank Dudemanfellabra for his idea too, I actually only slightly modified it. --V111P (talk) 06:52, 22 April 2014 (UTC)
- Really? Cool! I'm thrilled! - Gorthian (talk) 02:16, 22 April 2014 (UTC)
- No, I just used the template's "What links here" backlinks instead of the links in the template and it works! The former include all the pages that transclude the template. Thanks for the idea, Gorthian! I'll post the script a little later. --V111P (talk) 19:42, 21 April 2014 (UTC)
- I was thinking something along the lines of an invisible something in the navbox template that would tell the script "here are the links contained within," and then the script could note those and ignore them. Obviously, I'm no programmer; I don't know how any of this works. - Gorthian (talk) 19:25, 21 April 2014 (UTC)
- That wouldn't quite work, as many small cities in Texas have the template without being in the template (e.g. Hutchins, Texas). --V111P (talk) 13:43, 21 April 2014 (UTC)
- Not necessarily. You could prompt the user for the name of the navbox(es) that should be excluded (e.g. in this case {{Texas}} plus some others). Then you could query what links are inside that template and subtract those pages off from the whatlinkshere of the page. In navboxes, any link inside the template is also a link to that page.--Dudemanfellabra (talk) 17:03, 20 April 2014 (UTC)
- Here is the documentation for the script: User:V111P/js/What Links Here link filter. Tell me if you have any problems because I haven't done much testing. I tested it on Whichita Falls, Texas with Namespace set to (Article) and templates:
County, Texas|Template:Texas|Template:Texas county seats|Template:Texas cities and mayors of 100,000 population|Template:Texas counties
- It reduces the pages from 1841 to 755. Well, that's still a lot of pages... but I hope it's helpful anyway.
- If you want, Gorthian, you can try some of my other scripts too and tell me if you like/don't like them. Thanks. --V111P (talk) 06:52, 22 April 2014 (UTC)
Asynchronous ends too late
Hello. Here is a basic script that queries the API as explained in the documentation. But the result arrives too late, because the JS continues without waiting the api.get() finish, and numberOfEditors is [0, 0]. How can I stop the run until api.get() is really ".done()" ? emijrp (talk) 18:14, 22 June 2014 (UTC)
- You cannot use return in a callback; when done() is fired, there is nothing to return to, because the function already returned [0, 0]. You need to point the callback to a separate function.
-- [[User:Edokter]] {{talk}}
21:57, 22 June 2014 (UTC)- Using asynchronous I/O really requires a different way of looking at how a program operates. Assuming that you do not have significant additional processing to perform while the asynchronous operation is in process, you need to complete whatever operations you can/should do prior to getting the data from the asynchronous operation and then just return. You rely on getting a callback from the async op to start your processing back up again. You absolutely should not just sit and spin in a loop waiting for a flag to be set indicating completion. Doing so effectively changes the async op to synchronous which undermines the purpose of having asynchronous operations.
- The typical method to accomplishing this is that you continue everything that should happen after the asynchronous action is complete from the callback function passed to the function which actually initiates the asynchronous action. Very specifically, there is a period of time during which your script is not actually running, except for the asynchronous action.
- Conceptually, you really should not view it as something like a synchronous readFile(), but more of a requestURL(callWhenDataAvailable,callIfError). Your processing then stops, you return(), until you get a response. You should also set up a timeout so that you definitely get a callback to something that makes your script return to being processed. You should also initiate the async request as soon as you know that you are going to need it. Given that JS is, generally, single threaded, you don't have to worry about the issue of having the callback routing being called while you are still completing your initial processing.
- I'm not sure I've done a decent job of explaining this, but how much of the surrounding concepts should be explained here is not clear. From your question, the fundamental thing that appears to be an issue is that you have not made the paradigm shift in your thinking from how to use synchronous I/O to how to use asynchronous I/O. One of the things that appears to help people conceptually is to use the difference in nomenclature I indicated above (i.e. don't use getURL(), but requestURL()). This helps keep in mind that you are actually making a request for the data rather than starting a blocking I/O operation. — Makyen (talk) 00:53, 23 June 2014 (UTC)
Preloads for easier installing
Why are there no easy links to preloads to install scripts more easily? For example this link : [1] will automatically fill in the contents of the Template:! on a new section of the sandbox. Similarly, code could be appended to the bottom of the user's script page via preloads. The preload could perhaps be stored on the User:Example/Script.js/preload page. That would mean installing the script is only 1 click to open the user's script page, and 1 click to submit - instead of requiring the users to copy over the contents themselves.
From personal experience I say that in general it's best to do the work for users as much as possible, when it comes down to code. Of course this would not automatically insert the preload-link, but I think it would be good to add the option to add a preload link to the template. Any thoughts? Joeytje50 (talk) 21:28, 23 February 2014 (UTC)
- Creating these extra preload pages and hiding from the user what is actually happening is not a good idea in my opinion. Plus we can't have new sections in the script files. But thanks for the suggestion. --V111P (talk) 08:58, 20 April 2014 (UTC)
- A script could be made that adds a script to the user's javascript file. It would load the text of the file, append the new importScript() call, and edit the page with the new text. Then the user would only have to add a script once and then simply click a button to add new scripts. It could even be made to remove scripts if desired.--Dudemanfellabra (talk) 17:06, 20 April 2014 (UTC)
- You can try Equazcion's ScriptInstaller. Having to install a script in order to install another script kind of defeats its purpose though. But if you want to try many different scripts it makes sence. --V111P (talk) 23:24, 20 April 2014 (UTC)
- I think what you are asking for is detailed in the bug report I've tracked above and to the right. Maybe it will happen... I'm hoping. — {{U|Technical 13}} (e • t • c) 01:29, 23 June 2014 (UTC)
- You can try Equazcion's ScriptInstaller. Having to install a script in order to install another script kind of defeats its purpose though. But if you want to try many different scripts it makes sence. --V111P (talk) 23:24, 20 April 2014 (UTC)
- A script could be made that adds a script to the user's javascript file. It would load the text of the file, append the new importScript() call, and edit the page with the new text. Then the user would only have to add a script once and then simply click a button to add new scripts. It could even be made to remove scripts if desired.--Dudemanfellabra (talk) 17:06, 20 April 2014 (UTC)
Add only local scripts?
Means this page that only local "English WP" scripts are allowed? Script functions are mostly language independent (or can be made multilingual extended), is it not useful to add some more existing Wiki scripts? Concretely I would suggest an auto. signing script and an auto. section link corrector for the edit summary. This could also be useful as moduls for other scripts!? → User: Perhelion 22:39, 22 June 2014 (UTC)
- No, the scripts should work on this Wikipedia and they should be documented in English, but their source code doesn't have to be on the English Wikipedia. --V111P (talk) 19:03, 23 June 2014 (UTC)
Automatic totals for a table?
Following a discussion at WT:FOOTY#Career totals template, we were wondering if anyone here would be able to create a script to automatically total up the numbers from the rows above. For example, this could be used for medal tables, where the bottom row is a sum of all medals won, or for career statistics, such as at Scott Loach#Career statistics. - 97rob (talk) 15:30, 6 June 2014 (UTC)
- A link to the now archived discussion: #. I suggested using User:V111P/js/Sum numbers to sum the numbers manually. --V111P (talk) 19:44, 23 June 2014 (UTC)
Removing scripts
How do you change back to the default skin after you add a script? --UserJDalek 01:29, 8 August 2014 (UTC)
- Go to your common.js page and remove the line that imports any scripts you no longer want to affect your skin. You may have also added some custom CSS to your common.css page which you may want to remove.
- Gadgets are another possible way your skin may have been changed.
- For a completely default (vanilla) experience, reset all your gadgets to the default, and remove all the text from both your common.js and common.css pages. That should do it. fredgandt 01:40, 8 August 2014 (UTC)
- Thanks. --UserJDalek 02:04, 8 August 2014 (UTC)
- You're welcome. I might suggest (even though I do say so myself) that in future you use something like my userResourceManager (see the entry overleaf) to make the task of organising your enhancements easier. fredgandt 05:24, 8 August 2014 (UTC)
Using JS libraries
Hello. I'm starting to do user scripts, previously I did mostly Python bots. I'm thinking about a user script that shows charts/graphs using Flotr library or similar. Is it possible to use these libraries in a user script? How? Thanks. emijrp (talk) 18:00, 22 June 2014 (UTC)
- You can copy the contents of excanvas.min.js to a sub page of your user page and then load it from the main file of your user script, for example with
mw.loader.load('//en.wikipedia.org/w/index.php?title=User:Emijrp/excanvas.min.js&action=raw&ctype=text/javascript')
. You should also include the license [2] somewhere (the original Github page may disappears one day so just adding a link to it may not be enough). Another option is to try to load excanvas.min.js directly from Github, but I'm not sure if that's a good idea. --V111P (talk) 19:38, 23 June 2014 (UTC) - The simplest thing to do would be to copy the whole script directly into your user script. But what I like to do is to have a small main script file which loads the larger script when the user requests to use the tool. --V111P (talk) 23:45, 23 June 2014 (UTC)
- @Emijrp and V111P: is that license compatible with CC-BY-SA? If not, the script could not be
importedcopied to English Wikipedia. Helder 01:51, 8 August 2014 (UTC)- @Helder.wiki: Good question. I believe it is one-way compatible provided you keep the copyright notice, which is also required by CC-BY-SA. But of course, I'm not a lawyer, so I can't say for sure. To clarify, the question is whether you can copy the script to Wikipedia, I see no possible problem with importing the script from somewhere else with mw.loader.load(). --V111P (talk) 17:16, 9 August 2014 (UTC)
- See also Wikipedia:Village pump (policy)/Archive 98#Proper licensing of gadgets, user scripts and lua modules. Helder 18:30, 9 August 2014 (UTC)
- @Helder.wiki: Now I realize that technically we should probably license our user scripts with GPL v. 2 or later at least in addition to the default CC-BY-SA, otherwise we may be in violation of the license of the MediaWiki JavaScript modules we are using, including mw.loader. --V111P (talk) 22:22, 9 August 2014 (UTC)
- See also Wikipedia:Village pump (policy)/Archive 98#Proper licensing of gadgets, user scripts and lua modules. Helder 18:30, 9 August 2014 (UTC)
- @Helder.wiki: Good question. I believe it is one-way compatible provided you keep the copyright notice, which is also required by CC-BY-SA. But of course, I'm not a lawyer, so I can't say for sure. To clarify, the question is whether you can copy the script to Wikipedia, I see no possible problem with importing the script from somewhere else with mw.loader.load(). --V111P (talk) 17:16, 9 August 2014 (UTC)
- @Emijrp and V111P: is that license compatible with CC-BY-SA? If not, the script could not be
Copying from logs of IRC channel #wikimedia-dev connect:
<helderwiki> Since mw code is under GPL, does that mean any user script using mw.loader must also be licensed as GPL?
<helderwiki> (context: https://en.wikipedia.org/w/index.php?diff=620559132 )
<MatmaRex> whaaa? no
<MatmaRex> disclaimer: i am not a lawyer
* helderwiki neither
<MatmaRex> but i don't see how MW being licensed under GPL would force the on-wiki scripts to also be
<MatmaRex> it's not distributed together with them or anything
<helderwiki> Doesn't using these libraries makes the code "linked" to MW somehow?
<p858snake|l> iirc this has been discussed hundreds of time on the ML
<p858snake|l> and the answer is no
Helder 23:15, 9 August 2014 (UTC)
- OK, thanks. --V111P (talk) 00:28, 10 August 2014 (UTC)
- I'm also not a lawyer, but the way I'd look at it is from an almost purely technical perspective.
- A library imported by and for a user script is imported by the user, not by Wikipedia (JS being client side and all), so if the library is free to use in/on projects by whomever (unless you can somehow control who uses the script), load away!
- Consider if you will that use of Google's Maps in web pages must (Google says so, and that's the webmaster's agreement with Google) be accompanied by a clear privacy statement pointing out to the user of that web site, that by continued use, thay are agreeing to Google's use and privacy policies. It's not the webmaster that uses the Maps, it's the end user, so they're the ones who have to agree and be bound by Google's licencing and policies.
- The webmaster may have other policies and agreements with Google regarding the use of those imported resources, but they're strictly between the webmaster and Google, and have no practical bearing on the agreements between the end user and Google.
- However, the actual text added to any Wikipedia page could be contentious. i.e The call to load the library may need attribution(?) and certainly a full copy of a library might (depending on it's usage licencing thing).
- P.S. I'm kinda glad I'm not a lawer ;-) fredgandt 04:19, 10 August 2014 (UTC)
Comment on the WikiProject X proposal
Hello there! As you may already know, most WikiProjects here on Wikipedia struggle to stay active after they've been founded. I believe there is a lot of potential for WikiProjects to facilitate collaboration across subject areas, so I have submitted a grant proposal with the Wikimedia Foundation for the "WikiProject X" project. WikiProject X will study what makes WikiProjects succeed in retaining editors and then design a prototype WikiProject system that will recruit contributors to WikiProjects and help them run effectively. Please review the proposal here and leave feedback. If you have any questions, you can ask on the proposal page or leave a message on my talk page. Thank you for your time! (Also, sorry about the posting mistake earlier. If someone already moved my message to the talk page, feel free to remove this posting.) Harej (talk) 22:48, 1 October 2014 (UTC)
User script suddenly not working any more
I use User:קיפודנחש/watchlistScout.js to alert me when something on my watchlist changes. It is supposed to run on page load and refresh every 60 seconds afterwards. For the past day or so, though, I have been getting nothing from the script. All of my other scripts are working, I'm getting no errors on the javascript console, and it doesn't look like anything has changed in the code of the script recently (latest change was in 2012). Is there something else that may have changed site-wide that broke the script? Possibly an update to the API or something?--Dudemanfellabra (talk) 05:58, 11 October 2014 (UTC)
- I recently updated my own watchlist-related scripts to fix bugs which had caused them to be broken for over a year. I was wondering if that was causing your problem, but you apparently don't have them installed, so that probably isn't the cause. This doesn't fix your problem, but I thought I'd mention it in order to prevent other people searching blind alleys. --ais523 07:09, 11 October 2014 (UTC)
- @Dudemanfellabra: Why ask this here instead of on the script author's talk page? --V111P (talk) 22:00, 13 October 2014 (UTC)
- Hmm I suppose I should have done that--or at least pinged him/her--but since nothing had changed with the JS file itself and User:קיפודנחש's contributions don't show any recent edits that would have affected the script, I figured it wasn't his/her fault but some other error like a site-wide change that may have affected more than just this script. Seeing as how the people that watch this talk page are well versed in user scripts, I figured here would be a good place to ask. I also asked at the help desk, and they directed me to VPT, where I'm about to post as well.--Dudemanfellabra (talk) 02:32, 14 October 2014 (UTC)
- there was some change in module mediawiki.api in latest code update. i think i fixed the code to match the more modern style. peace - קיפודנחש (aka kipod) (talk) 04:15, 14 October 2014 (UTC)
- Hmm I suppose I should have done that--or at least pinged him/her--but since nothing had changed with the JS file itself and User:קיפודנחש's contributions don't show any recent edits that would have affected the script, I figured it wasn't his/her fault but some other error like a site-wide change that may have affected more than just this script. Seeing as how the people that watch this talk page are well versed in user scripts, I figured here would be a good place to ask. I also asked at the help desk, and they directed me to VPT, where I'm about to post as well.--Dudemanfellabra (talk) 02:32, 14 October 2014 (UTC)
Two questions
- Anyone know which gadget / tool / script / bot -- it is that re-orders cites for articles in the right order?
- What's the tool / gadget / script / bot -- that automatically or semi-automatically checks for archived versions of URLs and adds them into the citations with archiveurl parameter?
Thank you for your time,
— Cirt (talk) 19:39, 10 October 2014 (UTC)
- @Cirt: Any bot or human using AWB's general fixes will do #1. Don't know about #2, as I don't know how it would verify that the archived version supports the sentence in the article. GoingBatty (talk) 03:40, 7 November 2014 (UTC)
- Okay, no worries, and thank you, — Cirt (talk) 03:41, 7 November 2014 (UTC)
- GB I think for #2 he means searching webcite for archived versions of pages that now return 404 errors. If the citation was already there, it wouldn't be unreasonable to have a bot find a webcite version for it if it became a deadlink. That said, I have no idea what bot would do that. — {{U|Technical 13}} (e • t • c) 03:59, 7 November 2014 (UTC)