Jump to content

User:Novem Linguae/Scripts/DetectSNG.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Novem Linguae (talk | contribs) at 08:49, 22 July 2021 (create). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
// <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>