Jump to content

Wikipedia:User scripts/Requests/Archive 4

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Lowercase sigmabot III (talk | contribs) at 06:36, 10 December 2020 (Archiving 1 discussion(s) from Wikipedia:User scripts/Requests) (bot). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
Archive 1Archive 2Archive 3Archive 4Archive 5Archive 6Archive 9

Script to help automate G5 tagging

Frequently I check special:newpagesfeed and go to 'by blocked users.' A lot of the time the blocked users are sockpuppet accounts that have made 25+ articles that would have to be manually tagged. Tagging all these articles is tedious and I frequently find myself asking sysops on IRC to run a special:nuke. I am requesting a script that could semi-automatically go through and tag G5 eligible articles from a user's contributions page or page creation logs if it has not been edited by another editor and was created after a date that the user would input. Thanks to anyone that might be able to help! Kb03 (talk) 19:28, 8 March 2019 (UTC)

@Kb03: I don't think this is a good idea for a script. For example, Wikipedia:Bots/Requests for approval/PkbwcgsBot 6 was denied because nominating pages for deletion should always be reviewed (as you say you will do) - but it also ties in with communicating with the editors, etc. I'm uncomfortable making this script unless there is a consensus that it would be permissible. Sorry, --DannyS712 (talk) 19:46, 8 March 2019 (UTC)
DannyS712, would an RfC be appropriate for this? Kb03 (talk) 19:47, 8 March 2019 (UTC)
@Kb03: Probably. Maybe even a discussion at WT:CSD or WP:AN. The actual script should be relatively straightforward to create (its a small matter of programming) but the potential consequences make me hesitant. --DannyS712 (talk) 19:48, 8 March 2019 (UTC)
DannyS712, one question. when you quote "Communicating with the editors, etc" are you saying the creator of the article or an editor that may dispute the G5? Kb03 (talk) 20:33, 8 March 2019 (UTC)
@Kb03: I believe that @Xaosflux was referring to the creator. And yes, I understand that this doesn't usually apply with G5, but you should still review pages individually imo. --DannyS712 (talk) 20:35, 8 March 2019 (UTC)
Yes, as such a script could be used for any reason. Perhaps getting "csd-batch" added to Twinkle may be useful, and also automate appropriate settings. Leaving a note at AN/ANI should normally be fine for a NUKE request though - in nuke situations page tagging isn't needed. — xaosflux Talk 20:45, 8 March 2019 (UTC)
Xaosflux, would you have an issue with me requesting the feature be added on WT:Twinkle? Kb03 (talk) 20:58, 8 March 2019 (UTC)
Kb03, I'm not sure it's a good fit for Twinkle. Mass-G5 tagging isn't particularly common to most users, and isn't something I think we should suggest is readily encouraged. Mass-tagging is just mass-editing, I think if it's really dramatic people have used AWB, but really as Xaosflux said a post to AN/ANI would be more than appropriate; tagging is just beside the point, especially if they're already blocked. — Preceding unsigned comment added by Amorymeltzer (talkcontribs) 21:53, 8 March 2019 (UTC)
Kb03 guess it is kind of niche, there really isn't a good reason for anyone to spend time mass-tagging, since you can just ask at AN. — xaosflux Talk 22:48, 8 March 2019 (UTC)
Xaosflux, Could TW then have a function that automated posting to WP:AN for that reason? RhinosF1(chat)(status)(contribs) 07:51, 9 March 2019 (UTC)
@RhinosF1: That, on the other hand, is a simple script to create - its just new section: please new pages created by XYZ. I don't think it should be included in twinkle, because of how rare it is; ping @Amorymeltzer to chime in about the need for twinkle vs standalone script. --DannyS712 (talk) 07:54, 9 March 2019 (UTC)
I can have a script in beta within a few days --DannyS712 (talk) 07:55, 9 March 2019 (UTC)
DannyS712, What about mass protection requests? RhinosF1(chat)(status)(contribs) 08:04, 9 March 2019 (UTC)
@RhinosF1: That would be harder, because RFPP works differently, and has a specific format. AN is just &section=new and explaining the issue --DannyS712 (talk) 08:09, 9 March 2019 (UTC)
DannyS712, Amorymeltzer might be able to advise as Twinkle can do one at a time. Can I also suggest criteria like U5/G11 as a potential for your script? That gets quite quite a few being done at a time then the user never editing again. RhinosF1(chat)(status)(contribs) 08:12, 9 March 2019 (UTC)
@RhinosF1: let me start with just requesting a nuke, a build from there. I have to go, but I'll get back to you with a draft version soon --DannyS712 (talk) 08:23, 9 March 2019 (UTC)
@RhinosF1: Current script at User:DannyS712 test/nuke.js makes edits like this (I just need to change the target page to AN, but until then it targets my sandbox so feel free to test it). Thoughts? --DannyS712 (talk) 04:24, 10 March 2019 (UTC)
Extended discussion moved to User talk:DannyS712 test/nuke.js --DannyS712 (talk) 08:04, 10 March 2019 (UTC)
ToBeFree, weren't you redesigning WP:RfPP RhinosF1(chat)(status)(contribs) 18:19, 9 March 2019 (UTC)
DannyS712, that would be a good alternative. I see no problems with it. Kb03 (talk) 21:08, 9 March 2019 (UTC)
I have tried to do the same now. Because G5 only applies to pages "that have no substantial edits by others", I had to manually check the substantiality of all edits not made by the blocked user. I also had to verify that the sockpuppeteer had been blocked before the article has been created by a now-confirmed puppet. I'm not sure if a script can safely automate what I just did. If may be useful for easier cases, though.
@RhinosF1: yes; we're currently waiting for the bot to be updated. ~ ToBeFree (talk) 03:25, 10 March 2019 (UTC)

Redirect page tab behavior

Would really appreciate a script for commons.js, so that when I'm sitting on the Talk page of a Redirect page, and click the "Article" tab at the top of the page, it just takes me back to the Redirect article, and not to the target of it. Full details on this page at WP:VPP. Thanks! Mathglot (talk) 06:22, 9 May 2019 (UTC)

@Mathglot: I'm out of town currently, but I want to work on this. I should have something for you this weekend --DannyS712 (talk) 06:26, 9 May 2019 (UTC)
Wow, thanks! Do you need any additional information from me? Let me know. Mathglot (talk) 06:38, 9 May 2019 (UTC)
Paging User:Brion VIBBER, who may be interested in following this topic as well. Mathglot (talk) 06:49, 9 May 2019 (UTC)
@Mathglot: Can be done using a single line of JS. Just add the following to your common.js file: $("#p-namespaces a")[0].href += '?redirect=no'; This makes the subject page button not follow the redirect. Works for the vector skin, not sure about others. SD0001 (talk) 17:50, 9 May 2019 (UTC)
@SD0001: That seems to work fine, thanks! Also works for non-existent Project Talk pages (e.g., the TP belonging to Wikipedia:WPWO.) I wonder if there's a repository with links to helpful scripts like this one somewhere. Probably would make a lot of editors happy to customize their experience. This one immediately makes my life easier. Mathglot (talk) 19:49, 9 May 2019 (UTC)
@Mathglot and SD0001: Additional line so that the Read tab links to the redirect itself: $("#p-views a")[0].href += '?redirect=no';. It's possible that these both could be merged into one line, but I don't know JQuery or JS in general well enough to tell.
I've also note I've reopened T5324 Tthe underlying Phabricator issue; there's more discussion here. eπi (talk | contribs) 01:51, 10 May 2019 (UTC)

Hi, @SD0001, DannyS712, and E to the Pi times i:, Just a heads up that about some unforeseen knock-on effects that this fix may have provoked; see WP:VPT#Invalid url from Create tab. I think this is a minor enough issue that it doesn't really need to be fixed, now that I'm aware of it; but I wanted to draw your attention to it, in case you're interested. In a nutshell: if the url already has a query string, then either the positioning of the added redirect= param or its delimiter might need to be altered. Thanks, Mathglot (talk) 23:52, 10 May 2019 (UTC)

@Mathglot: Yeah, that one's probably my fault. I copied SD0001's script, but I didn't consider the effects it would have on the right tab. But it's not an unfixable problem; it just needs to be more discerning about how it modifies the URL. eπi (talk | contribs) 01:52, 11 May 2019 (UTC)

oh sorry, didn't foresee that bug. if ($("#p-namespaces a")[0].className.includes('mw-redirect')) $("#p-namespaces a")[0].href += '?redirect=no'; Here, now the ?redirect=no will be added only if the subject page is a redirect, removing all issues. Haven't tested this since I'm on phone. Tell me if it doesn't work. SD0001 (talk) 03:38, 11 May 2019 (UTC)

@Mathglot: Just tested this and it works. If you also want the "Read" tab to not follow redirect, you need if ($("#ca-view a")[0].className.includes('mw-redirect')) $("#ca-view a")[0].href += '?redirect=no'; SD0001 (talk) 06:42, 12 May 2019 (UTC)
@SD0001: thanks. I wasn't quite clear if I need only the last one (@06:42) for Talk & Read, or both (03:38 & 06:42). Mathglot (talk) 08:01, 12 May 2019 (UTC)

Automatic American English

I want the reverse of Ohconfucious's American → British script so that it could convert British → American. IDK why it hasn't been done already. — Mr. Guye (talk) (contribs)  08:32, 26 July 2018 (UTC)

Do you have a link to the original script? --Danski454 (talk) 16:39, 3 August 2018 (UTC)
Is this the page in question? --Kailash29792 (talk) 16:49, 3 August 2018 (UTC)
I think this might be it: User:Ohconfucius/script/EngvarB.js --Danski454 (talk) 17:38, 3 August 2018 (UTC)
Danski454, Ohconfucious does not appear to have responded to a request to make a script that can convert British English to American. Are you working on it? Or does Canadian English follow the same style? --Kailash29792 (talk) 11:44, 24 August 2018 (UTC)
Kailash29792 I am not working on this script. Also, Canadian English is somewhere between British and American. Danski454 (talk) 18:47, 25 August 2018 (UTC)
I must thank Ohconfucius for making this possible, so this request may be archived. --Kailash29792 (talk) 08:54, 13 September 2018 (UTC)
No, this request should not be archived. There still is not an automatic edit script that converts British English to American English, nor does it seem like anyone is trying to create one. My request is far from fulfilled. — Mr. Guye (talk) (contribs)  01:25, 15 September 2018 (UTC)
Is anyone working on this? If not, I can take a stab at it. Warpaltarpers (talk) 16:05, 30 May 2019 (UTC)

Another editor in support of this script - Atsme Talk 📧 21:09, 20 July 2019 (UTC)

Watchlist notifier: number of (automated) updates in browser page title

Automated updates of live blogs are often indicated by a number between brackets shown in the browser's page title, signifying the number of recent changes. The inboxes of most e-mail services display the same, as do Twitter pages. Would it be possible to add a gadget that allows for automated updates of Watchlists (for all projects) with such a notifier in the browser (tab) page titles as well? For me, and I guess for many other users, it would be a major improvement, not having to manually check watchlists anymore and instead being able to view live updates while working in other browser windows. I am not sure if this has been proposed before – if so, my apologies. Jürgen Eissink (talk) 14:24, 17 July 2019 (UTC).

@Jürgen Eissink: that would require the javascript to run when the window isn't in focus, and I'm not sure that is supported. But, you may want to check out User:DannyS712/Global watchlist, which shows you your watchlist from multiple sites. Hope that helps --DannyS712 (talk) 20:01, 17 July 2019 (UTC)
I didn't actually mean a Watchlist for all projects in one, but the possibility to have the proposed feature activated on the different projects (in my case mainly nl., en., de. en Commons). And it doesn't seem like DannyS712 uses automatic updates and a page title signifier, which is specifically what I am inquiring about. Thousands of pages of pages run without the window in focus, I don't see why this would be a problem for specific Wikipedia pages. Oh, I now see you are DannyS712. Thanks for your answer, anyway. Jürgen Eissink (talk) 20:25, 17 July 2019 (UTC).
@Jürgen Eissink: clarification: I'm not sure wikipedia's support for user-defined javascript (eg at your /common.js) will run when the window isn't in focus. I could be wrong though --DannyS712 (talk) 21:50, 17 July 2019 (UTC)
Someone else, who I consider an expert, gave me the impression that it would technically be easy to implement. Let's wait for other reactions. Thanks so far. Jürgen Eissink (talk) 21:58, 17 July 2019 (UTC).
@Jürgen Eissink: I ran some tests. You're right, sorry --DannyS712 (talk) 22:13, 17 July 2019 (UTC)
@DannyS712: That sounds hopeful, thanks! I myself am not enough focused on programming to grasp every possibility, so I have to rely on others in these matters. Jürgen Eissink (talk) 22:19, 17 July 2019 (UTC).
@Jürgen Eissink: User:SD0001/watchlist-update-title.js. SD0001 (talk) 18:52, 18 July 2019 (UTC)
@SD0001: Well, thank you, SD0001, but it doesn't seem to be working for me yet. I copied your script to a new .js-page in my user space, but it doesn't seem to update automatically and neither are the numbers of changed pages displayed in the page title. Am I getting it wrong? Pinging @DannyS712: also. Jürgen Eissink (talk) 20:20, 18 July 2019 (UTC).
Oh, I now see that I have to copy it to my common.js, which I just did. Will try and see again. Jürgen Eissink (talk) 20:30, 18 July 2019 (UTC).
Is this supposed to automatically update the Watchlist when working in another window? If so, how often will it update? Doesn't do anything so far. Jürgen Eissink (talk) 21:07, 18 July 2019 (UTC).
@Jürgen Eissink: It will work only if "Live updates" button on watchlist is selected. (there seems to be no preferences option to have it selected automatically - it has to be selected every time you open your watchlist, but if you wish I can tweak the script to have it selected every time the watchlist is opened). When the watchlist undergoes a live update (done by the mediawiki software, not by this script), the script just updates the page' HTML title prefixing it with a "(1)" or "(2)" or so on. This number is removed when the window comes into focus (i.e, when you switch over to the tab from another, or if you click anywhere within the window if you were already on it).
To install it across all wikis, add
mw.loader.load('//en.wikipedia.org/w/index.php?title=User:SD0001/watchlist-update-title.js&action=raw&ctype=text/javascript');
on your global.js page on meta. Or to your common.js locally for use on a specific wiki. I'd suggest doing this rather than copy-pasting the code as you've done so that any updates/improvements I may make will become available to you automatically. SD0001 (talk) 03:24, 19 July 2019 (UTC)
Okay, that makes sense and now it seems to be working, although so far I've seen updates marked (1) when there were more pages added. So the count seems to be the update and not the number of pages updated, which I'd prefer. A small issue is that when pressing 'Mark all changes as seen' that the counter again appears and will only go away after refreshing the page, which is counterproductive to the initial purpose. I'll keep testing a bit, and while improvements would be welcomed, I thank you for the code! Jürgen Eissink (talk) 11:40, 19 July 2019 (UTC).
It takes some time to get used to this new feature, but the first experiences are satisfying. Thank you once again. I will also keep an eye on DannyS712's developments. Thank you both. Jürgen Eissink (talk) 20:27, 19 July 2019 (UTC).
@Jürgen Eissink: now "Live updates" will automatically be enabled. Counter will count number of new edits rather than watchlist updates. Also fixed the issue with Mark all changes as seen button. SD0001 (talk) 19:31, 20 July 2019 (UTC)
@SD0001: that is pretty amazing and quite literally exactly what I had in mind, so I couldn't be more grateful. I hope more users will find it useful, and I am actually somewhat surprised that this is a first. Thank you again. Jürgen Eissink (talk) 19:40, 20 July 2019 (UTC). P.S. Maybe it's good to list this on Wikipedia:User scripts/List#Watchlist?
One last improvement could be, @SD0001:, that one's own edits are not counted, but I don't know if that is possible. Jürgen Eissink (talk) 21:18, 20 July 2019 (UTC).
It's possible, but isn't it better to just hide one's own edits from the watchlist? There's an option in Preferences for that. SD0001 (talk) 07:19, 21 July 2019 (UTC)
Well I do see the benefit nevertheless for people who don't have that option on. Will add it. SD0001 (talk) 08:27, 21 July 2019 (UTC)
I use the script, because it's convenient to me, but maybe on minor detail could be improved: when hovering over the page histories, those page histories are not updated – would it be possible to add this? Thanks. Jürgen Eissink (talk) 13:32, 26 July 2019 (UTC).

Convert sfn to CS1

What the title says. Leave the sfn(s) if they are botched i.e. the corresponding reference can't be tracked. WBGconverse 14:43, 2 August 2019 (UTC)

WikiProject status

I just want a lightweight script that will allow me to manually fill in the parameters for {{WikiProject status}}. Pretty much exactly like User:Evad37/rater, but simpler and only for one banner template. –MJLTalk 20:16, 9 July 2019 (UTC)

Might do, if nobody takes this before end-September. WBGconverse 14:44, 2 August 2019 (UTC)

Wanted cross-wiki reporting tool

  • I am writing here in the spirit of knowing if there is a possibility of having twinkle or any other tool to report users/ips on crosswiki noticeboards? on meta/local.
  • Basically twinkle with local/global choice or new script to report users would be great help. thanks QueerEcofeminist "cite! even if you fight"!!! [they/them/their] 02:31, 6 August 2019 (UTC)

Template:Infobox journal filler/inserter

It would be super, super useful if we could have a one-click script that could insert a partially pre-filled {{infobox journal}} in articles, or rebuild existing ones.

Basically it would insert the default

{{Infobox journal
| title         = 
| image         = <!-- or |cover= -->
| image_size    = 
| alt           = 
| caption       = 
| former_name   = <!-- or |former_names= -->
| abbreviation  = <!-- ISO 4 abbreviation -->
| bluebook      = <!-- For law journals only -->
| mathscinet    = <!-- For the MathSciNet abbreviation IF different from ISO 4 abbreviation-->
| nlm           = <!-- For the NLM abbreviation IF different from ISO 4 abbreviation-->
| discipline    = <!-- or |subject= -->
| peer-reviewed = 
| language      = 
| editor        = <!-- or |editors= -->
| publisher     = 
| country       = 
| history       = 
| frequency     = 
| openaccess    = 
| license       = 
| impact        = 
| impact-year   = 
| ISSNlabel     = 
| ISSN          = 
| eISSN         = 
| CODEN         = 
| JSTOR         = 
| LCCN          = 
| OCLC          = 
| website       = 
| link1         = 
| link1-name    = 
| link2         = <!-- up to |link5= -->
| link2-name    = <!-- up to |link5-name= -->
}}

(and remove {{italic title}} or its redirect if present) in the lead, like so, and would take existing {{infobox journal}} found in articles and standardize them to the above layout, importing whatever parameters it found. Extra non-empty parameters could just be appended, one per line, below |link2-name=, in alphabetical order. Headbomb {t · c · p · b} 00:35, 29 July 2019 (UTC)

Additionally, it could automatically populate certain fields, like

  • |title=, could be {{PAGENAME}}, with a warning to verify the name, in case we have an infobox journal on a non-journal article (e.g. like a society that publishes the journal).
  • |abbreviation= could be determined by putting {{PAGENAME}} in [1], with a warning to verify the abbreviation, especially for non-English titles, or for non-journal articles
    • [2] could be used to compute the abbreviation for non-English titles (treat multilingual as English)

Headbomb {t · c · p · b} 00:54, 29 July 2019 (UTC)

Going to @Tokenzero: who may have some insight here as well. Headbomb {t · c · p · b} 01:10, 29 July 2019 (UTC)
Still looking into it... my thoughts for now: it would probably be best to use a solid parser like mwparserfromhell: using it to do the basic reformatting of a chosen infobox would be much easier and probably always more robust than any amount of hand-crafted regexes. Looking at mw:Alternative parsers gives essentially two options: Parsoid (the parser behind the visual editor and a few other tools; seems harder to use but can run directly in browser) or python (mwparserfromhell or wikitextparser; easier for me but requires setting up some server to communicate with your browser), I'm still looking into these. Meanwhile, I also learned about TemplateData: ideally the formatting, suggested fields and their ordering could be taken from there, right?
About the UI: you're thinking of e.g. an additional menu entry "add/normalize infobox" on the article page, which would take you to the editing screen with a proposed diff? Tokenzero (talk) 22:58, 2 August 2019 (UTC)
Yeah, taken to diff window would be good yes. Headbomb {t · c · p · b} 04:13, 3 August 2019 (UTC)
I've got a template parser at User:Evad37/extra.js (parseTemplates function), if anyone wants to try using that to make a userscript. - Evad37 [talk] 03:46, 3 August 2019 (UTC)
Thanks! That should work indeed (Parsoid turns out to be overkill and as far as I see it does not allow modifying templates/finding their position with a stable or documented API).
 Partly done Here's my first attempt: importScript('User:Tokenzero/infoboxJournal.js'); // Backlink: [[User:Tokenzero/infoboxJournal.js]]. Does not pre-populate fields yet, only adds defaults, reformats, reorders, and then removes {{italic title}}. It should display an 'Infobox journal' portlet under the 'More' menu. On an edit page it just modifies the textarea, on an article view page it redirects you to the diff page. Tokenzero (talk) 20:03, 9 August 2019 (UTC)
I'll try it later tonight! Very much looking forward to it! Headbomb {t · c · p · b} 21:19, 9 August 2019 (UTC)
@Tokenzero: first thing is it should give an edit summary. Headbomb {t · c · p · b} 01:18, 10 August 2019 (UTC)
[3] add |formernames= as an alias of |former_name= Headbomb {t · c · p · b} 01:26, 10 August 2019 (UTC)
Ok, edit summary is now Add infobox journal (IJ.js) or Reformat infobox journal (IJ.js) (or do you prefer just ce? Also I don't care about the link to the script, I can remove it if preferred). Added aliases |formernames= and |formername=. New infoboxes are now inserted after all initial templates. Tokenzero (talk) 09:03, 10 August 2019 (UTC)
"Adding/standardizing infobox journal with User:Tokenzero/infoboxJournal.js" depending on if it's added, or if one already exists. The link could be an 'instruction page' on how to add/use the script, but it might be worth waiting until it's a bit more polished to have that link. Headbomb {t · c · p · b} 12:07, 10 August 2019 (UTC)
Summary changed, links to User:Tokenzero/infoboxJournal. Pre-filling should now work for |language= and |frequency=. Tokenzero (talk) 13:01, 10 August 2019 (UTC)
Looks good. Only thing that's a bit weird is that saving using the premade summary gives a warning that there is no edit summary. A few scripts seem to be doing that. I wonder why. Headbomb {t · c · p · b} 16:29, 10 August 2019 (UTC)
Fixed: 'wpAutoSummary' should have been set to md5 of empty string. If a script wants users to change the premade summary (e.g. because it's just tagging the script name), the intended behaviour is to set 'wpAutoSummary' to md5 of it. By the way, do you know any user-script that redirect to the edit or diff page? Tokenzero (talk) 18:55, 10 August 2019 (UTC)

not sure what "do you know any user-script that redirect to the edit or diff page" means, but you could take a look at WP:Citation expander. Headbomb {t · c · p · b} 19:15, 10 August 2019 (UTC)

Any script that takes you from the view page to the edit or diff page with proposed changes. I just found that tricky to do and I wonder if there's a better way :) Citation expander, as far as I see, either works directly on the edit page (so it won't show you a diff) or from a web page that submits the edit before you can see the diff (which is much easier to do). Tokenzero (talk) 19:26, 10 August 2019 (UTC)
If you use the Citations button, you're taken to a diff. Headbomb {t · c · p · b} 19:38, 10 August 2019 (UTC)

Empty parameters

Is there a script that removes empty parameters in the cite web template like "df=" that is pretty much always empty? --Mazewaxie (talkcontribs) 13:28, 26 August 2019 (UTC)

t = t.replace(/\|\s*(?:df|mf|dmy|mdy)\s*\=\s*(?=[\|\}])/g, "");
where t is the wikitext, which you've hopefully obtained in some previous step.
Note that this whacks any parameter with one of the four names above (without regard to template name or amount of spacing), just as long as it's blank.
Removal of any blank parameter (but only from specific templates) (if that's what you actually need) would be a bit more complicated to pattern-match because preceding parameter values could contain any number of nested invocations of other templates.
cobaltcigs 06:56, 11 October 2019 (UTC)

An sidebar on the right would be nice!

Having a floating sidebar on the right of the screen would allow for quicker use of Wikipedia, and I would like this to be implemented as a script (if possible). Cheers! creativeRajat@lk 16:20, 14 October 2019 (UTC)

Check out the Timeless skin (in your preferences) if you're not afraid of everything else looking different as well. Can't find anything in WP:US/L about a right-hand sidebar, but I feel like I remember one existing. Enterprisey (talk!) 04:44, 16 October 2019 (UTC)

unreliable.js, a predatory journals/vanity press highlighter

Resolved

Similar to User:Anomie/linkclassifier.js/User:Anomie/linkclassifier.css, I'd like a user script to highlight citations to predatory journals and vanity presses. The regex can be stolen/adapted from Special:AbuseFilter/891.

Basically, if a URL with a domain that matches the urls := part, highlight those links by making them... let's say pinkpink/some annoying color. Likewise, if a DOI matches the dois : part, highlight those in annoying pink as well (doi:10.4172/omicsjournalofnonsense unflagged free DOI (link)→doi:10.4172/omicsjournalofnonsense). Or whatever other colour. If the script cannot dynamically be kept in sync with Special:AbuseFilter/891, I can take over and put it at User:Headbomb/unreliable.js and maintain it after that.

The idea is that, if you encounter a citation like

You get presented with something like

And know something's off. Multiple 'classes' and colors should be supported (each customisable as enabled/disabled), so that additional things like blacklisted links and possibly unreliable sources (like Forbes.com, which will often be fine, but sometimes not) can also be highlighted. Headbomb {t · c · p · b} 07:16, 6 February 2020 (UTC)

The basic version would look like this:
var PREDATORY_HREFS_RGX = /academicjournals\.com|academicjournals\.net|academicjournals\.org|academicpub\.org|academicresearchjournals\.org|aiac\.org\.au|aicit\.org|alliedacademies\.org|ashdin\.com|aspbs\.com|avensonline\.org|biomedres\.info|biopublisher\.ca|bowenpublishing\.com|ccsenet\.org|cennser\.org|clinmedjournals\.org|cluteinstitute\.com|cpinet\.info|cscanada\.net|davidpublisher\.org|etpub\.com|eujournal\.org|growingscience\.com|hanspub\.org|hoajonline\.com|hrmars\.com|iacsit\.org|iamure\.com|\.idosi\.org|igi-global\.com|iises\.net|imedpub\.com|informaticsjournals\.com|innspub\.net|intechopen\.com|intechweb\.org|interesjournals\.org|ispacs\.com|ispub\.com|julypress\.com|juniperpublishers\.com|kowsarpub\.com|kspjournals\.org|m-hikari\.com|macrothink\.org|mathewsopenaccess\.com|mecs-press\.org|oapublishinglondon\.com|oatext\.com|omicsonline\.org|ospcindia\.org|researchleap\.com|sapub\.org|scholink\.org|scialert\.net|scidoc\.org|sciencedomain\.org|sciencedomains\.org|sciedu\.ca|sciencepg\.com|sciencepub\.net|sciencepubco\.com|sciencepublication\.org|sciencepublishinggroup\.com|scipg\.net|scipress\.com|scirp\.org|scopemed\.com|sersc\.org|sphinxsai\.com|\.ssjournals\.com|thesai\.org|waset\.org|witpress\.com|worldwidejournals\.com|zantworldpress\.com/i;

var PREDATORY_DOIS_RGX = /doi.org\/10\.(11648|1166|1234|12677|12692|12720|12988|13005|13172|13188|14257|14303|14419|1453|14569|14662|15415|15373|15761|17265|18005|18052|18311|18775|19030|19044|19070|19080|1999|20472|20849|20902|21102|21767|22158|23937|2495|30654|30845|35841|36648|3844|3923|3968|4018|4156|4172|4236|4303|5267|5296|5376|5430|5455|5539|5567|5580|5772|5812|5815|5829|5897|5899|5923|5963|6007|7243|7439|7537|7575|7718|7763|9734)/i;

var cssRules = {
	"margin-right": "0.1em",
	"padding": "3px 4px 2px",
	"background-color": "#ffdddd",
	"border": "1px",
	"border-radius": "3px",
	"box-shadow": "0.1em 0.1em 0.25em rgba(0,0,0,0.75)",
	"-moz-box-shadow": "2px 2px 4px #A0A080",
	"-webkit-box-shadow": "2px 2px 4px #A0A080",
	"box-shadow": "2px 2px 4px #A0A080"
};

$('.mw-parser-output a.external').each(function() {
	if (PREDATORY_HREFS_RGX.test(this.href)) {
		$(this).css(cssRules);
	} else if (PREDATORY_DOIS_RGX.test(this.href)) {
		$(this).css(cssRules);
	}
});
Hopefully someone else can do the rest and provide customisability you ask for.
You should definitely simplify the massive regex (for instance, make the .com part common for all .com domains) for better performance. SD0001 (talk) 12:43, 6 February 2020 (UTC)
I can regex, what I can't do is .js from scratch, but the above should give me enough to get started. I'll give that piece of code a shot this afternoon. Performance probably isn't much of an issue. Headbomb {t · c · p · b} 13:54, 6 February 2020 (UTC)
@SD0001: User:Headbomb/unreliable.js doesn't seem to work, including your original code. This can be tested on Science Publishing Group, which has both a url and doi that should match. Headbomb {t · c · p · b} 14:45, 6 February 2020 (UTC)
Nevermind, I had a brainfart. Namely, I forgot to do this. Headbomb {t · c · p · b} 16:04, 6 February 2020 (UTC)
I should have mentioned that for it to load reliably, it needs to be ensured that the page has fully loaded before the script code is run. You can do this by wrapping the whole code between (function() { ... script code comes here ... })();
I see that you removed doi.org from the DOIs regex - this would mean that anyinnocentdomain.com/3424310.11648 would be flagged, as the link's url contains "10.11648". Markup like (doi)*?[ ]*?[=\|\:][ ]*? won't work here as we're checking against the HTML of the page (specifically, against external link URLs), not against the wikitext. [4] the i makes the regex test case-insensitive. SD0001 (talk) 17:16, 6 February 2020 (UTC)
Good to know. Didn't know about /i, but that will be useful. As for removing doi.org, that's desired to pickup "Journal of crap 10.4172/asdf10354" that might not make use of templates. false positives are far and few between, although normally I might add a final ...\/ at the end to ensure it matches a 10.4172/ and not just 10.4172. Clearly "(PRED_DOIS_RGX.test(this.href))" needs tweaking to look outside hrefs, but to what, I don't yet know. Headbomb {t · c · p · b} 17:21, 6 February 2020 (UTC)
@Headbomb: You can check whole reference texts (anything within <ref> tags) by using code like:
$('span.reference-text').each(function() {
    if (DOI_RGX.test(this.textContent)) {
        $(this).css(CSSRULE);
    }
});
SD0001 (talk) 17:47, 6 February 2020 (UTC)

@SD0001: Well, I don't want this to be restricted to ref tags either. I want to find those wherever on the page they may be. Headbomb {t · c · p · b} 17:56, 6 February 2020 (UTC)

 Done Also, if something could only be detected/highlighted in specific namespaces, that would be good. For instance the current var WIKI_HREFS_RGX should really only be highlighted in main/draft spaces. Headbomb {t · c · p · b} 23:27, 6 February 2020 (UTC)

@SD0001:, any idea for how to look outside of references/links? Headbomb {t · c · p · b} 01:33, 11 February 2020 (UTC)

@Headbomb: Thanks for all your work on this so far! When finished, I do think this will be a very useful script, particularly for NPP/AFC folks.
Regarding looking outside references, it's a bit complicated. We'll need to iterate over all the text nodes on the page, extract the index at which the search hit begins, and wrap that in a span element, upon which we can then apply custom stylings. I can code this for you when I have time. But where the does the desire for doing this outside ref tags come from? SD0001 (talk) 18:02, 12 February 2020 (UTC)

@SD0001: A typical example would be in further reading section or external link sections where you could have something like

==Further reading
* Smith, J. (2019) "Article of things" ''Journal of Nonsense'' doi: 10.4172/123456798

It doesn't need to highlight the whole doi (although that would be neat if it could), but just the prefix/whatever it matches would be enough. Headbomb {t · c · p · b} 18:08, 12 February 2020 (UTC)

TFD holding cell: button to mark template as ready for deletion

So I actually do have a suggestion/request. One thing that would be great is to be able to use this in the Holding cell. What I mean by that is that when a template that is currently listed in one of the holding sections is ready to be deleted, it would be great to be able to just click a button and have the entry moved to the bottom and to have the template in question updated as ready for deletion. Food for thought... --Zackmann (Talk to me/What I been doing) 00:24, 11 February 2019 (UTC)
Does that make any sense? Not sure if I did a great job explaining it... --Zackmann (Talk to me/What I been doing) 19:32, 15 February 2019 (UTC)
Yeah, something like this should be possible. I'll move this thread to WT:XFDC so this suggestion doesn't get lost in my talk page archives. - Evad37 [talk] 02:20, 16 February 2019 (UTC)
Thinking about this further, it's probably better off as a separate script – I don't think being part of XFDcloser would save a significant amount of code - Evad37 [talk] 01:06, 20 November 2019 (UTC)
Ping @Zackmann08: - Evad37 [talk] 01:12, 20 November 2019 (UTC)
Alternatively we could just stop bothering with the delete=1 business since it's completely useless anyway. ‑‑Trialpears (talk) 13:07, 3 December 2019 (UTC)

Extract data from a frozen VisualEditor

Often VisualEditor ends up frozen and won't allow me to save or switch to markup-mode, giving instead a "docserver-http-error", "500", or "404" error (when the article has been renamed while I was editing). This happens about once a day.

It seems VisualEditor's API doesn't allow for extracting the markup data without connecting to the server.

I have two ugly ideas for how to solve this:

1. Regularly log wikimarkup when using VisualEditor to prevent loss of data when it freezes

  • Every 30 seconds, generate wiki-markup and console.log it.
  • If the connection to the server is broken, alert() me so that I may retrieve my markup from the console and reload the editor.

2. Extract the data model

  • Extract the data model, copy it to my clipboard
  • Reload the window
  • Paste the data model, and the user script applies it to the new instance of VisualEditor

Or if anyone knows a better way to retrieve data from a frozen VisualEditor, that'd be good to know.

With thanks, – Thjarkur (talk) 22:40, 3 August 2019 (UTC)

@Whatamidoing (WMF): Any ideas/comments? SD0001 (talk) 04:58, 21 October 2019 (UTC)
Þjarkur, the data model is actually already saved to localsession storage in your browser. If you randomly refresh the page during an editor session, you will note a small notification top right: "Changes recovered; Your unsaved changes have been automatically recovered". No idea however what happens when the page is moved during that time. It probably wasn't designed with that in mind. You might consider opening a phabricator ticket on that feature request, as it is not an uncommon situation I'd think. —TheDJ (talkcontribs) 09:22, 21 October 2019 (UTC)
SD0001, thanks for the ping. I really appreciate it when editors let me know about conversations. Thjarkur, thanks for posting about the problems you were having. I apologize for the delay in finding it. Inside the visual editor, there's a ? menu. At the end of that menu is an item for leaving feedback on the software. That posts your note over on MediaWiki.org, where the devs are likely to find it faster.
Yes, the ability to (usually) recover unsaved changes already exists. If the visual editor crashes, but your web browser doesn't, then you should be able to select-all and copy everything (or just the changes you were making) and then paste them back in. It won't work in 100% of the cases, but it usually works for me.
There was a spate of 404 problems recently. That's a separate thing (all about mw:RESTBase, and supposedly it's finally fixed now (as of last WP:THURSDAY?). Hopefully you're already seeing fewer of these problems. Whatamidoing (WMF) (talk) 17:10, 23 October 2019 (UTC)
The Restbase improvements did lessen the problem but I still run in to this way too often. The cookie-autosave is cleared if you accidentally clicked on Escape or clicked out of the VisualEditor, I think the cookie has only saved me in about 5% of cases. Does anybody know a way to interact with the VisualEditor instance in Javascript? – Thjarkur (talk) 15:51, 9 December 2019 (UTC)

PROD handler

A script to make it a bit less time consuming for patrolling admins to assess proposed deletions. Single click to open a dialog which would check if:

  • the page has ever been PRODed before
  • the page has ever been nominated for deletion before
  • the page has ever been undeleted
  • the talk page has any content other than WikiProject templates

and buttons to:

  • open what links here (articles only) in a new tab or list them in the dialog
  • open the talk page in a new tab or show it in the dialog
  • accept the PROD and delete the page, talk page, and redirects
  • decline the PROD because ineligible or for a custom reason

--kingboyk (talk) 18:18, 13 February 2020 (UTC) (ping appreciated if there is a reply)

I now recall that the PROD template itself is supposed to indicate if the article has already been at AfD.
In recent days I have had to decline PRODs due to the article having been PRODded before (this is often difficult or impossible to spot in the history) and one where the article had previously been undeleted. --kingboyk (talk) 13:19, 14 February 2020 (UTC)
See Wikipedia:Unreviewed featured articles, Template:Article history, and Wikipedia:Featured article review (FAR)

It would be grand if someone were able to generate a list of current FAs ordered (oldest to newest) by the date of their last review (FAC or FAR), and including their mainpage date if they have run WP:TFA.

This will help in making sure that dated FAs are reviewed at FAR, and that FAs that have not yet run on the mainpage could be prioritized.

  • Current FAs are found at Category:Featured articles
  • Date of last review is found on the article talk page, in the {{Article history}} template, searching on the actionNdate for the highest N where actionN containes either FAC or FAR.
    • Return for the highest N containing FAC or FAR (whichever is latest) the date and link found in |actionNdate= and |actionNlink=
  • Mainpage date is found in the article history template on the article talk page as |maindate=
  • The list, tabulated from oldest date of last review to newest, would be placed at WP:URFA, looking like:
Date last
FAC or FAR
TFA date Article Most recent FAC or FAR Notes
2006-11-02 2020-03-03 Tourette syndrome Wikipedia:Featured article candidates/Tourette syndrome
2020-09-26 2008-04-26 Manzanar Wikipedia:Featured article review/Manzanar/archive1

The notes field would be left blank for reviewers to fill in: for example, we would put on Tourette syndrome that it was completely overhauled for 2020 TFA.

If it makes for less work, it's not really necessary to have FAs that passed FAC after 2017-01-01 ... the idea is to look at the very old FAs.

Thanks! SandyGeorgia (Talk) 21:53, 9 November 2020 (UTC)

@SandyGeorgia:  Done I put it at User:SDZeroBot/Featured articles. Hopefully met all your requirements :D – SD0001 (talk) 21:20, 20 November 2020 (UTC)
Totally awesome ... I am checking through it now and will get back to you. SandyGeorgia (Talk) 21:42, 20 November 2020 (UTC)

User:SD0001 One query (I can adjust this manually unless you tell me it indicates an underlying problem in the script):

  1. Cretan War (205–200 BC) returned no last FAC/FAR date

And that is the only issue I uncover. I checked a couple of FAs that have convoluted histories of being featured, de-featured, and re-featured, and this looks perfect.

Would you mind moving the list to Wikipedia:Unreviewed featured articles/2020 ??

Thank you for the amazing work; I must seek out the perfect barnstar! SandyGeorgia (Talk) 22:06, 20 November 2020 (UTC)

SandyGeorgia, Indeed that indicated an underlying problem: the script wasn't configured to deal with "actionN" where N was a 2 digit number. Fixed it and re-run. Also moved it to project space. – SD0001 (talk) 22:51, 20 November 2020 (UTC)
Awesome, we are all set if anyone wants to archive this. SandyGeorgia (Talk) 23:35, 20 November 2020 (UTC)

Good article reassessment script

The process to nominate an article for good article reassessment is very time consuming and rather complicated (see the procedure laid out at Wikipedia:Good article reassessment), and I'd imagine that a script could automate this. Might be better as a twinkle feature— not sure—but here's my (with no coding experience) idea: an option to nominate it for individual or community reassessment, based upon what is selected the script will create the correct subpage. Then there could be a spot to type in the rationale and ideally the script would notify the original ga nominator and the original reviewer and any wikiprojects tagged on the talk. In my mind this would be like a combination of how twinkle handles XfD's and merge discussions, not sure how hard it would be to do, but as I anticipate nominating a lot of poor quality articles for reassessment soon, it could be very helpful. Best wishes, Eddie891 Talk Work 16:31, 19 June 2020 (UTC)

Noting that this was  Done (User:SD0001/GAR-helper). See WT:TW#Good article reassessments. SD0001 (talk) 09:38, 16 July 2020 (UTC)

Userscript help

Resolved

I have imported a userscript from Meta-Wiki and have it at User:FlightTime/confirm-logout.js. I've tried to contact the author, but they seem to be inactive. The script asks for a conformation for logout, as seen here File:Logout screenshot.png. The script uses RGB color calls, What would be perfect would to change all RGB calls to Hex triplet, if that is not possible then the outcome I'm looking for is as follows:

background: #EEEEEE;

border: 2px solid #0000FF; (also the button borders)

text: #000

I am trying to match the boxes on my talk page

Any and all help will be greatly appreciated. Please ping me with comments/results. Thank you for your time, - FlightTime (open channel) 20:32, 23 February 2020 (UTC)

@FlightTime: Make the following changes:
  • warning: {text: "rgba(255, 255, 255, 1)", background: "rgba(221, 51, 51, 1)"},
  • warning: {text: "#000", background: "#EEE"},
  • "en_us": "<div style='margin-bottom: 0.5em; '>You clicked on a log-out link. Do you want to continue?</div><div><button>No</button><button onclick='window.location=\"/wiki/special:logout\"'>Log out</button></div>",
  • "en_us": "<div style='margin-bottom: 0.5em; border: 2px solid #00F'>You clicked on a log-out link. Do you want to continue?</div><div><button style='border: 2px solid #00F; color: #000'>No</button><button style='border: 2px solid #00F; color: #000' onclick='window.location=\"/wiki/special:logout\"'>Log out</button></div>",
I think these will work. That whole script could do with a bit of cleanup, since you probably aren't using all of it's features. Regards, guywan (talkcontribs) 00:23, 21 March 2020 (UTC)
@Guywan: Wow :) Thank you, I was thinking I wasn't going to get a reply. Let's see if I can do this right (if you'd like I can put the script on a subpage, not sure if the author is maintaining it). Thanx again. Cheers, — Preceding unsigned comment added by FlightTime (talkcontribs) 00:25, 21 March 2020 (UTC)

A script to help build an "open tasks" list of things you'd like to monitor

Sometimes, when I throw out an idea on a more obscure talk page, there's no one around to see it and it gets lost (or, at a super busy talk page, there are too many competing discussions and it gets buried). When I make a post I fear this might happen to, I often add the page to my watchlist so I can follow up on it or send out invites if needed later, but this isn't fully optimal, since for obscure pages I might never get reminded to follow up if there's no other activity, and for busy pages it clogs up my watchlist. I'd love to have a userscript that I could use to easily build up a list of such discussions on a subpage of my user page. I envision it working by allowing you to go into a mode on any page where you can click on a section, and it'll add a link to that discussion on your subpage. On the subpage itself, it'd allow you to easily move tasks between the open/active category and a "done" category for completed matters and a "abandoned" category for failed/not-worth-the-effort matters. Does anything like that exist, and if not would anyone be interested in taking this on? (I'm hoping this proposal doesn't itself become one of those things I forget about.) Sdkb (talk) 00:22, 29 March 2020 (UTC)

@Sdkb: Check out the scripts in WP:User scripts/List#Todo lists. I think ToDoLister does most of those things. SD0001 (talk) 08:51, 31 March 2020 (UTC)

A script to handle file renaming requests

A script to handle file renaming requests, which will do following this:

  • Rename the file
  • Remove the {{Rename media}} template.
  • Update file links

Similar to commons:MediaWiki:Gadget-AjaxQuickDelete.js. -- CptViraj (📧) 13:58, 2 March 2020 (UTC)

@CptViraj: Very exciting! I might be able to do this. I'll start working on it some time. Regards, guywan (talkcontribs) 23:59, 20 March 2020 (UTC)
Ye thankyou. Regards! -- CptViraj (📧) 03:33, 21 March 2020 (UTC)
I do lots of file moving, this script would be terrific. - FlightTime Phone (open channel) 16:09, 24 March 2020 (UTC)
@CptViraj and FlightTime: Unveiling FileMoverHelper. While on File: pages, it creates a link in the More portlet (if you use the Vector skin) called FMH. Click on that link to get started. I recommend checking the results the first few times and letting me know if something goes horribly terribly wrong. Best of luck. guywan (talkcontribs) 23:05, 2 April 2020 (UTC)
@Guywan: I moved File:Trails of Cold Steel IV Japanese Cover.png to File:Trails of Cold Steel IV Cover Art.png but the script didn't update the file link at The Legend of Heroes: Trails of Cold Steel IV. And if possible can we have custom reason option too? Thankyou! -- CptViraj (📧) 03:48, 3 April 2020 (UTC)
@CptViraj: Should be fixed. You will now be prompted for a move reason. guywan (talkcontribs) 15:26, 3 April 2020 (UTC)
@Guywan: File:Flash Comics (Feb 1948) cover art.png didn't update file link this time too. Custom reason is working fine. -- CptViraj (📧) 16:05, 3 April 2020 (UTC)
@CptViraj: Now it should be fixed, hopefully. guywan (talkcontribs) 18:42, 3 April 2020 (UTC)