User:מקף/global.js

From Meta, a Wikimedia project coordination wiki

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
//TwinkleGlobal
//mw.loader.load('//meta.wikimedia.org/w/index.php?title=User:Xiplus/TwinkleGlobal/load.js&action=raw&ctype=text/javascript');
if ([''].indexOf(mw.config.get('wgDBname')) === -1) {
    mw.loader.load('//meta.wikimedia.org/w/index.php?title=User:Xiplus/TwinkleGlobal/load.js&action=raw&ctype=text/javascript');
}


//Convenient Discussions
mw.loader.load('//commons.wikimedia.org/w/index.php?title=User:Jack_who_built_the_house/convenientDiscussions.js&action=raw&ctype=text/javascript');

//פופאפים | popup (he)
mw.loader.load('//he.wikipedia.org/w/index.php?title=MediaWiki:Gadget-popup.js&action=raw&ctype=text/javascript');

//שחזור עם תקציר | revert summery (he)
mw.loader.load('//he.wikipedia.org/w/index.php?title=MediaWiki:Gadget-rollBackSummary.js&action=raw&ctype=text/javascript');

//MoreMenu
mw.loader.load('https://meta.wikimedia.org/w/index.php?action=raw&ctype=text/javascript&title=MediaWiki:MoreMenu.import.js');

//עריכה מהשוואת קוד מקור | edit from diff | en:User:Jon Harald Søby/diffedit
mw.loader.load('//meta.wikimedia.org/w/index.php?title=User:Jon_Harald_Søby/diffedit.js&action=raw&ctype=text/javascript');

//UserInfoPopup | חלונית פעילות המשתמש
mw.loader.load("https://en.wikipedia.org/w/index.php?title=User:Guycn2/UserInfoPopup.js/min.js&action=raw&ctype=text/javascript");

//Vandal Cleaner | טיפול מהיר בטרולים ובמשחיתים כבדים
mw.loader.load( 'https://he.wikipedia.org/w/index.php?title=מדיה_ויקי:סקריפטים/107.js&action=raw&ctype=text/javascript ');
mw.config.set( 'vandalCleanerSkipFirstConfigPanel', true );

//VisualFileChange
//mw.loader.load('//commons.wikimedia.org/w/index.php?title=MediaWiki:Gadget-VisualFileChange.js&action=raw&ctype=text/javascript');

//syntax highlighter
//mw.loader.load('//www.mediawiki.org/w/index.php?title=MediaWiki:Gadget-DotsSyntaxHighlighter.js&action=raw&ctype=text/javascript');

//גלילת יומנים אין־סופית | User:Awesome Aasim/infiniscroll.js
//mw.loader.load('//en.wikipedia.org/w/index.php?title=User:Awesome Aasim/infiniscroll.js&action=raw&ctype=text/javascript');

//הוספת כפתורים
$.when(mw.loader.using('mediawiki.util'), $.ready).then(function () {
	var v = mw.util.getParamValue("diff");
	var v0 = mw.util.getParamValue("oldid");
	var BaseUrl = (v || v0 ? window.location.href : "https://" + mw.config.get("wgServerName") + "/w/index.php?title=" + mw.config.get("wgPageName"));
	p_views_ul_li = $('#p-views ul li').eq(0); // Tab to put the new tabs before (usually "Read")
	//ניקוי המטמון של דף	|	Reload
	var node = mw.util.addPortletLink(
		"p-tb",
		BaseUrl + "&action=purge",
		"ניקוי מטמון", ""/* 'id'*/, "ניקוי המטמון של הדף הזה", "r"/*, 'nextnode'*/);
	// Credit - https://meta.wikimedia.org/wiki/User:Krinkle/Scripts/Countervandalism.js#L-39
	$(node).on('click', function (e) {
		var tag = 'snippet-purge-' + (++$.guid);
		mw.notify('ריענון...', { tag: tag });
		new mw.Api().post({ action: 'purge', titles: mw.config.get('wgPageName'), forcelinkupdate: '1' }).then(function () {
			mw.notify('הנתונים רועננו', { tag: tag });
			location.reload();
		}, function () {
			mw.notify('רענון הנתונים כשל', { type: 'error', tag: tag });
		});
		e.preventDefault();
	});
	//מידע על הדף	|	Info
	mw.util.addPortletLink(
		"p-views",
		BaseUrl + "&action=info",
		"ℹ️", ""/* 'id'*/, "מידע על הדף", "i", p_views_ul_li)
	//דפי משנה |	Under
	mw.util.addPortletLink(
		"p-views",
		"https://" + mw.config.get("wgServerName") + "/wiki/Special:PrefixIndex?prefix=" + mw.config.get("wgPageName") + "&stripprefix=" + mw.config.get("wgNamespaceNumber"),
		"u↲", ""/* 'id'*/, "דפי משנה", "u", p_views_ul_li);
	//עריכה חזותית בכל הדפים	|	Visual
	mw.util.addPortletLink(
		"p-views",
		BaseUrl + "&veaction=edit",
		"v✏️", ""/* 'id'*/, "עריכה באמצעות העורך החזותי בכל מרחב שם", "v", p_views_ul_li);
	//עריכת תגיות גרסה	| Label
	if (v || v0) {
		mw.util.addPortletLink(
			"p-cactions",
			BaseUrl + "&action=editchangetags&ids%5B" + (v ? v : v0) + "%5D=1",
			"תגיות", ""/* 'id'*/, "עריכת תגיות", "l"/*, 'nextnode'*/);
	}

	//מוסיף לחצן השוואת דפים
	mw.util.addPortletLink(
		'p-cactions',
		mw.util.getUrl('Special:ComparePages', { page1: mw.config.get('wgPageName') }),
		'השוואת דפים');

	/**
	 * SWViewer
	 * See [https://meta.wikimedia.org/wiki/SWViewer]
	 * Authored by Tulsi Bhagat [https://meta.wikimedia.org/wiki/User:Tulsi_Bhagat]
	 * [:M:User:Tulsi/swviewer.js]
	 */
	mw.util.addPortletLink(
		'p-tb',
		'//swviewer.toolforge.org/',
		'SWViewer',
		't-swviewer',
		'Launch SWViewer',
		'',
		'#t-info'
	);
}
);

/** מוסיף קישור בתפריט הצד "כלים" לבדיקת העתקה בדפים **/
/* [[משתמש:1Or/סקריפטים שכתבתי]]המקור מהדף של  */
/* [[משתמש:1Or/copy.js]] */
mw.util.addCSS('#my-copy-check a { /*font-weight:bold; color: magenta;*/ }');
mw.loader.using(['mediawiki.util']).then(function () {
	mw.util.addPortletLink(
		"p-tb",
		"http://tools.wmflabs.org/copyvios/?lang=he&project=wikipedia&title=" + mw.config.get('wgRelevantPageName'),
		"בדיקת העתקה",
		"my-copy-check",
		"לחץ כאן לבדיקת סבירות שתוכן הדף הועתק ממקור אחר"
	);
	$('#my-copy-check a').attr('target', '_blank');
});


//כפתורי תרומות וסטטיסטיקות למשתמשים | ContribsTabVector | credit en:User:Equazcion/ContribsTabVector.js
mw.loader.using(['mediawiki.util', 'mediawiki.Uri'], function () {
	"use strict";
	var username, p_views_ul_li, contribsTabUrl, contribsTabStatsUrl, CATabUrl;

	// Set default options for any that haven't been set
	function setDefault(option, val) {
		if (window[option] === undefined) {
			window[option] = val;
		}
	}
	setDefault('contribsTabName', 'Ctrbs');
	setDefault('contribsTabNumber', 50);
	setDefault('contribsTabStats', true);
	setDefault('contribsTab', true);
	setDefault('contribsTabStatsName', 'Stats');
	setDefault('CATabName', 'CA');
	setDefault('CATab', true);

	username = mw.config.get('wgRelevantUserName');
	if (!username) {
		return; // Don't do anything if we're not on a page with a relevant username (i.e. User or User talk)
	}

	p_views_ul_li = $('#p-views ul li').eq(0); // Tab to put the new tabs before (usually "Read")

	if (window.contribsTab) { // Construct the contribs tab, if it's not turned off
		// Construct contribs URL
		contribsTabUrl = mw.util.getUrl('Special:Contributions', {
			target: username,
			limit: window.contribsTabNumber
		});

		mw.util.addPortletLink(
			'p-views',
			contribsTabUrl,
			window.contribsTabName,
			'ca-contributions',
			'Show this user\'s contributions',
			null,
			p_views_ul_li
		);
	}

	if (window.CATab) { // Construct the CA tab, if it's not turned off
		// Construct CA URL
		contribsTabUrl = mw.util.getUrl('Special:CentralAuth', {
			target: username,
		});

		mw.util.addPortletLink(
			'p-views',
			contribsTabUrl,
			window.CATabName,
			'ca-CA',
			'Show this user\'s CentralAuth',
			null,
			p_views_ul_li
		);
	}

	if (window.contribsTabStats) { // Construct the stats tab, if it's not turned off
		// Construct stats URL
		contribsTabStatsUrl = new mw.Uri('//tools.wmflabs.org/xtools-ec/')
			.extend({
				user: username,
				project: mw.config.get('wgDBname')
			})
			.toString();

		mw.util.addPortletLink(
			'p-views',
			contribsTabStatsUrl,
			window.contribsTabStatsName,
			'ca-statistics',
			'Show this user\'s editing statistics',
			null,
			p_views_ul_li
		);
	}
});

if (['loginwiki', 'metawiki'].indexOf(mw.config.get('wgDBname')) !== -1) {
    document.querySelectorAll('.mw-userlink[href^="/w/index.php?title=User:"]').forEach(function(e) {
        var href = e.getAttribute('href');
        var username = href.match(/title=User:(.*?)(&|$)/)[1];
        var link = document.createElement('a');
        link.href = '/w/index.php?title=Special:CentralAuth&target=' + username;
        link.textContent = '▤';
        var sup = document.createElement('sup');
        sup.appendChild(link);
        e.parentNode.insertBefore(sup, e.nextSibling);
    });
}