User:Novem Linguae/Scripts/DetectSNG.js
Appearance
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
![]() | This user script seems to have a documentation page at User:Novem Linguae/Scripts/DetectSNG. |
// <nowiki>
/*
- Let reviewer know when certain [[WP:SNG]] keywords are detected. This helps to determine if the article meets an obscure SNG and is therefore notable.
*/
mw.loader.using('mediawiki.storage').then(function () {
mw.storage.session.set( 'client-error-opt-out', '1' );
});
$(function() {
let wordString = `
Ryder Cup, Presidents Cup, Solheim Cup
World Golf Hall of Fame
PGA Tour, LPGA Tour, European Tour, PGA Tour Champions
U.S. Amateur, British Amateur
Men's major golf championships, Women's major golf championships, Senior major golf championships
PGA, LPGA, European, Champions Tour
`;
let wordArray = wordString.replace(/, /g, "\n").trim().split("\n");
console.log(wordArray);
// don't run when not viewing articles
let action = mw.config.get('wgAction');
if ( action != 'view' ) return;
// don't run when viewing old revisions
let latestRevision = mw.config.get('wgCurRevisionId');
let currentRevision = mw.config.get('wgRevisionId');
if ( latestRevision != currentRevision ) return;
// Only run in mainspace and draftspace
let namespace = mw.config.get('wgNamespaceNumber');
if ( ! [0, 118].includes(namespace) ) return;
// check Wikicode for SNG keywords, case insensitive
// if detected
// print "SNG keywords detected: X, Y, Z" at the top of the page, and highlight
});
// </nowiki>