Wikipedia:WikiProject User scripts/Scripts/Unwatch: Difference between revisions

Content deleted Content added
m Protected Wikipedia:WikiProject User scripts/Scripts/Unwatch: protect against abuse - arbitrary code injection [edit=sysop:move=sysop] [cascading]
m Remove legacy globals per phab:T72470 (via WP:JWB)
 
(3 intermediate revisions by one other user not shown)
Line 2:
 
Other versions:
* [[User:Ilmari_Karonen/unwatch.js]] (''legacy script'')
* [[User:Omegatron/monobook.js/unwatch.js]]
* [[User:Quarl/watchlist.js]]
* [[user:js/watchlist]]
* [[User:Matthewmayer/monobook.js]]
* [[User_talk:Alex_Smotrov/wlunwatch.js|wlUnwatch]] — same script but uses ajax so you don't leave the page at all
* [[Bugzilla:424]] (if implemented)
 
*/
<pre><nowiki> */
 
addOnloadHook(function () {
 
// Check if we're on the watchlist
if (!mw.config.get('wgCanonicalSpecialPageName') || mw.config.get('wgCanonicalSpecialPageName') != "Watchlist") return;
if (!document.forms[0] || !document.forms[0].namespace) return;
 
// Unwatch links go back to watchlist with "Removing requested items from watchlist..." message
var query_prefix = "title="+encodeURIComponent(mw.config.get('wgPageName'))+"&action=submit&remove=1&id[]=";
 
// ...or...
Line 38 ⟶ 36:
// create unwatch link and append it after history link
var unwatch = document.createElement('a');
unwatch.href = mw.config.get('wgServer') + mw.config.get('wgScriptPath') + "/index.php?" + query_prefix + encodeURIComponent(links[i].title);
unwatch.title = "Unwatch "+links[i].title;
unwatch.appendChild(document.createTextNode("unwatch"));
Line 50 ⟶ 48:
}
});
 
// </nowiki></pre>