Jump to content

User:NguoiDungKhongDinhDanh/CopyvioChecker.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.
/* This script adds CopyvioCheck tab to all pages, except for Special ones. Vector skin only.
Originally written by NguoiDungKhongDinhDanh.

Installing this script: Try using Enterprisey's ScriptInstaller, or paste the following line into your vector.js or common.js/global.js (not recommended for non-Vector user):
mw.loader.load('//en.wikipedia.org/w/index.php?title=User:NguoiDungKhongDinhDanh/CopyvioChecker.js&action=raw&ctype=text/javascript');

Since I'm not very active and 'scripty', should the gadget have glitches, well, my apologise for being irresponsible. */

mw.loader.using( ['mediawiki.util', 'mediawiki.Uri'], function () {
	"use strict";
	var CvCkTabUrl;

	function setDefault( option, val ) {
		if ( window[option] === undefined ) {
			window[option] = val;
		}
	}
	setDefault( 'CvCkTabName', 'CopyvioCheck' );
	setDefault( 'CvCkTab', true );	
	
	if ( mw.config.get( 'wgNamespaceNumber' ) == -1 ) {
		return;
	}

	if ( window.CvCkTab ) {
		CvCkTabUrl = new mw.Uri( '//copyvios.toolforge.org/' )
			.extend( {
				lang: mw.config.get( 'wgServer' ).replace(/\//g, '').split('.')[0],
				project: mw.config.get( 'wgServer' ).replace(/\//g, '').split('.')[1],
				oldid: (mw.config.get( 'wgRevisionId' )===0) ? (mw.config.get( 'wgCurRevisionId' )) : (mw.config.get( 'wgRevisionId' )),
				action: 'search',
				use_engine: '1',
				use_links: '1',
				turnitin: '1',
			} )
			.toString();

		mw.util.addPortletLink(
			'p-cactions',
			CvCkTabUrl,
			window.CvCkTabName,
			'CopyvioCheck',
			'Submit a query to copyvios.toolforge.org',
			null,
			null
		);
	}
} );