User:BethNaught/ECD.js

From Wikipedia, the free encyclopedia
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.
/** 
 * Attribution: a cut-down and modified version [[User:Ahecht/Scripts/CVD.js]],
 * itself based on [[User:Technical 13/Scripts/CVD.js]].
 */

/** global  mw, $ */

mw.loader.using('mediawiki.util', function() {
    $(document).ready( function() {
		mw.util.addPortletLink(
			'p-tb',
			'#',
			'Earwig\'s CV Detector',
			'p-cv-detector',
			'Scan for copyright violations using Earwig\'s Copyvio Detector tool. (This will open in a new tab/window)'
		).addEventListener('click', function(e) {
			e.preventDefault();
			var siteName = mw.config.get('wgSiteName').toLowerCase();
			if(!/mediawiki|wikibooks|wikidata|wikimedia|wikinews|wikipedia|wikiquote|wikisource|wikiversity|wikivoyage|wiktionary/.test(siteName)) { siteName = 'wikipedia'; }
			window.open('https://tools.wmflabs.org/copyvios?lang=' + mw.config.get('wgContentLanguage') + '&project=' + siteName + '&title=' + encodeURIComponent(mw.config.get('wgPageName')), '_blank');
		});
	});
});