Wikipedia:User scripts/Requests/Archive 4: Difference between revisions

Content deleted Content added
m Archiving 1 discussion(s) from Wikipedia:User scripts/Requests) (bot
m Replaced deprecated <source> tags with <syntaxhighlight>
 
(One intermediate revision by one other user not shown)
Line 27:
 
 
[[Category:Wikipedia scripts| ]]
[[Category:Non-talk pages that are automatically signed]]
 
Line 77 ⟶ 76:
::::{{re|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 <sourcesyntaxhighlight lang=js>mw.loader.load('//en.wikipedia.org/w/index.php?title=User:SD0001/watchlist-update-title.js&action=raw&ctype=text/javascript');</sourcesyntaxhighlight> on your [[m:Special:Mypage/global.js|global.js page on meta]]. Or to your [[Special:Mypage/common.js|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. [[User:SD0001|SD0001]] ([[User talk: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! [[User:Jürgen Eissink|Jürgen Eissink]] ([[User talk:Jürgen Eissink|talk]]) 11:40, 19 July 2019 (UTC).
Line 184 ⟶ 183:
Is there a script that removes empty parameters in the cite web template like "df=" that is pretty much always empty? --[[User:Mazewaxie|<strong><span style="color: #606060;">Mazewaxie</span></strong>]] ([[User talk:Mazewaxie|<span style=" color: #606060;">talk</span>]] • [[Special:CentralAuth/Mazewaxie|<span style="color: #606060;">contribs</span>]]) 13:28, 26 August 2019 (UTC)
 
: <sourcesyntaxhighlight lang="javascript">t = t.replace(/\|\s*(?:df|mf|dmy|mdy)\s*\=\s*(?=[\|\}])/g, "");</sourcesyntaxhighlight>
: where <code>t</code> 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.
Line 210 ⟶ 209:
 
:The basic version would look like this:
:<sourcesyntaxhighlight lang=js>
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;
 
Line 234 ⟶ 233:
}
});
</syntaxhighlight>
</source>
: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. [[User:SD0001|SD0001]] ([[User talk:SD0001|talk]]) 12:43, 6 February 2020 (UTC)
Line 244 ⟶ 243:
:::::::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 <code>...\/</code> at the end to ensure it matches a <code>10.4172/</code> and not just <code>10.4172</code>. Clearly "<code>(PRED_DOIS_RGX.test(this.href))</code>" needs tweaking to look outside hrefs, but to what, I don't yet know. &#32;<span style="font-variant:small-caps; whitespace:nowrap;">[[User:Headbomb|Headbomb]] {[[User talk:Headbomb|t]] · [[Special:Contributions/Headbomb|c]] · [[WP:PHYS|p]] · [[WP:WBOOKS|b]]}</span> 17:21, 6 February 2020 (UTC)
::::::::{{re|Headbomb}} You can check whole reference texts (anything within &lt;ref> tags) by using code like:
::::::::<sourcesyntaxhighlight lang=js>
$('span.reference-text').each(function() {
if (DOI_RGX.test(this.textContent)) {
$(this).css(CSSRULE);
}
}); </sourcesyntaxhighlight> [[User:SD0001|SD0001]] ([[User talk:SD0001|talk]]) 17:47, 6 February 2020 (UTC)
{{unindent}} {{Re|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. &#32;<span style="font-variant:small-caps; whitespace:nowrap;">[[User:Headbomb|Headbomb]] {[[User talk:Headbomb|t]] · [[Special:Contributions/Headbomb|c]] · [[WP:PHYS|p]] · [[WP:WBOOKS|b]]}</span> 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 <code>var WIKI_HREFS_RGX</code> should really only be highlighted in main/draft spaces. &#32;<span style="font-variant:small-caps; whitespace:nowrap;">[[User:Headbomb|Headbomb]] {[[User talk:Headbomb|t]] · [[Special:Contributions/Headbomb|c]] · [[WP:PHYS|p]] · [[WP:WBOOKS|b]]}</span> 23:27, 6 February 2020 (UTC)