Jump to content

User:TimothyBlue/common.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.
importScript( 'User:Enterprisey/copy-section-link.js' ); // Backlink: [[User:Enterprisey/copy-section-link.js]]
importScript('User:Pythoncoder/voteSymbols.js'); // Linkback: [[User:Pythoncoder/voteSymbols.js]]
importScript( 'User:RealFakeKim/Scripts/pageInfo.js' ); // Backlink: [[User:RealFakeKim/Scripts/pageInfo.js]]
importScript("User:PleaseStand/userinfo.js");
importScript( 'User:DannyS712/DiscussionCloser.js' );// [[User:DannyS712/DiscussionCloser.js]]
importScript( 'User:MPGuy2824/MoveToDraft.js' ); // Backlink: [[User:MPGuy2824/MoveToDraft.js]]
importScript( 'User:Anne drew Andrew and Drew/gigawatch.js' ); // Backlink: [[User:Anne drew Andrew and Drew/gigawatch.js]]
mw.loader.load( '/w/index.php?title=User:Writ_Keeper/Scripts/deletionFinder.js&action=raw&ctype=text/javascript' ); // Backlink: [[User:Writ Keeper/Scripts/deletionFinder.js]]
importScript('User:Lourdes/AfDList.js'); // Linkback: [[User:Lourdes/AfDList.js]]
mw.loader.load( '/w/index.php?title=User:Evad37/OneClickArchiver.js&action=raw&ctype=text/javascript' ); // Backlink: [[User:Evad37/OneClickArchiver.js]]
importScript("User:PleaseStand/highlight-comments.js");

// mw.loader.load('//en.wikipedia.org/w/index.php?title=User%3ATheopolisme%2FScripts%2Fadminhighlighter.js&action=raw&ctype=text/javascript'); 
// [[User:Theopolisme/Scripts/adminhighlighter.js]]
// importScript('User:Anomie/linkclassifier.js'); // Linkback: [[User:Anomie/linkclassifier.js]]
// importScript("User:PleaseStand/highlight-comments.js");
// importScript('User:Salix alba/Citoid.js');
// importScript('User:Svick/HarvErrors.js'); // Backlink: [[User:Svick/HarvErrors.js]]
// importScript("User:Awesome Aasim/xfdvote.js");
// importScript('User:Evad37/rater.js'); // [[User:Evad37/rater]]
// mw.loader.getScript("/w/index.php?title=User:Guywan/Scripts/HistoryHighlight.js&action=raw&ctype=text/javascript"); // Backlink: [[User:Guywan/Scripts/HistoryHighlight.js]]
// importScript( 'User:Suffusion of Yellow/mark-reverted.js' ); // Backlink: [[User:Suffusion of Yellow/mark-reverted.js]]
// importScript( 'User:Danski454/stubsearch.js' ); // Backlink: [[User:Danski454/stubsearch.js]]
// 4importScript('User:SD0001/StubSorter.js'); // [[User:SD0001/StubSorter.js]]
// importScript('User:Þjarkur/Highlight recently added text.js');
// mw.loader.load( '/w/index.php?title=User:Chlod/Scripts/FoldArchives.js&action=raw&ctype=text/javascript' ); // Backlink: [[User:Chlod/Scripts/FoldArchives.js]]
// importScript('User:SD0001/GAR-helper.js'); // [[User:SD0001/GAR-helper.js]]
// mw.loader.load( '/w/index.php?title=User:Evad37/EditWarChecker.js&action=raw&ctype=text/javascript' ); // Backlink: [[User:Evad37/EditWarChecker.js]]

//-----------------------------------------------------------
//Full scripts

// CustomSummaryPresets
importScript( 'User:Enterprisey/CustomSummaryPresets.js' ); // Backlink: [[User:Enterprisey/CustomSummaryPresets.js]]
var customGeneralSummaries = [
"Disputed change. Discuss on article talk page",
"Disputed change. Discuss on article talk page per [[WP:BRD]] and gain [[WP:CONSENSUS]] before making changes.", 
"Failed [[WP:V]]. rm unrefed per [[WP:BURDEN]].",
"Failed [[WP:V]]. Entry does not meet list inclusion criteria.",
"Unexplained/disputed deletion of sourced content. Discuss on talk page and gain consensus.",
"Add maintenance tags. Maintenance tags should only be removed when the problem is fix. [[Help:Maintenance template removal|See Here]] for information on how and when maintenance tags should be removed.",
"Do not remove maintenance tags without fixing the problem. [[Help:Maintenance template removal|See here]] for an explanation of how and when to remove maintenance tags.",
"Add citation needed sourcing tags to unsourced content. Per [[WP:BURDEN]], unsourced material may be removed from article at any time.", 
"rv unconstructive edit",
"rm [[WP:OR]]/[[WP:SYNTH]]",
"rm/rv per [[WP:NOTDIRECTORy]]",
"ce/fmt/cleanup",
"cleanup links. See [[MOS:LINK]], [[WP:REDLINK]], [[WP:EL]], [[MOS:SEEALSO]] for guidelines related to links",
"cleanup sections. See [[WP:MOSLAYOUT]], [[MOS:OVERSECTION]], [[MOS:APPENDIX]], and [[WP:SECTIONORDER]] for info related to sections and article layout",
"rm content per [[WP:WEIGHT]]/[[WP:UNDUE]].",
"rv edit that contradicts talk page consensus.",];
/* user contribution links – adds "edit" and "info" links: (diff|hist|edit|info) */
/* page history links – adds "source" link: (cur|prev|source) */
/* backwards compatible to MediaWiki ~2019 */

// initialize
var c_shortcuts = {};
	// localization
c_shortcuts.l10n_base = {
	en: {
		'source': 'source',
		'edit': 'edit',
		'info': 'info'
	},
	de: {
		'source': 'Quelltext',
		'edit': 'Bearbeiten',
		'info': 'Informationen'
	}
};
c_shortcuts.language = "en"; // fallback if loading configuration fails
if (typeof mw != "undefined") c_shortcuts.language = mw.config.values.wgUserLanguage; // get language setting
if ( ! c_shortcuts.l10n_base[c_shortcuts.language] ) language="en"; // fallback if untranslated
function l10n(msg) { return c_shortcuts.l10n_base[c_shortcuts.language][msg]; }

	// functions
c_shortcuts.addHistoryShortcut = function(action,label,class_name,parent_element,shortcut_URL_source_class) {
			// generate shortcut URL
			if (! label) label=action;
			if (contribution.querySelector("."+shortcut_URL_source_class)) {
				shortcut_URL=parent_element.querySelector("."+shortcut_URL_source_class).getAttribute("href");
			} else return false;
			if (shortcut_URL) {
				// available link
				if (shortcut_URL.toString().indexOf("&action") > 0) shortcut_URL=shortcut_URL.replace(/&action.*?(&|$)/,"");
				shortcut_URL+="&action="+action;

				parent_element.querySelector(".mw-changeslist-links").appendChild(document.createElement("span"));
				parent_element.querySelector(".mw-changeslist-links").lastElementChild.classList.add(class_name);
				parent_element.querySelector(".mw-changeslist-links").lastElementChild.innerHTML=' <a href="'+shortcut_URL+'">'+l10n(label)+'</a>';
			} else {
				// missing link
				parent_element.querySelector(".mw-changeslist-links").appendChild(document.createElement("span"));
				parent_element.querySelector(".mw-changeslist-links").lastElementChild.classList.add(class_name);
				parent_element.querySelector(".mw-changeslist-links").lastElementChild.innerHTML=' '+l10n(label);
			}
};



// main
if (document.getElementsByClassName("mw-contributions-list").length == 0 && ! document.getElementById("pagehistory") ) {
	console.debug("no page history found");
} else {

c_shortcuts.contribution_count = 0;
c_shortcuts.day_count  = 0;

// determine whether the page is a page history or user contribution list
if (document.getElementById("pagehistory") ) {
	// is page history
	c_shortcuts.history_type="pagehistory";
	console.debug("page history detected");
	c_shortcuts.history_container = document.getElementById("pagehistory");
}	else { 
	// user contributions
	c_shortcuts.history_type="contributions";
	console.debug("user contributions detected");
	c_shortcuts.history_container = document.getElementsByClassName("mw-contributions-list")[0].parentElement;
}

// select history items on page
if (c_shortcuts.history_type == "pagehistory") {
	c_shortcuts.contribution_list = document.getElementById("pagehistory").getElementsByTagName("li");
} else if (c_shortcuts.history_type == "contributions") {
	c_shortcuts.contribution_list = document.getElementsByClassName("mw-contributions-list")[0].parentElement.getElementsByTagName("li");
}

c_shortcuts.number_of_days = c_shortcuts.history_container.getElementsByTagName("h4").length;
if (c_shortcuts.number_of_days == 0) c_shortcuts.number_of_days=1; // backwards compatibility

for ( c_shortcuts.contribution_count = 0; c_shortcuts.contribution_count < c_shortcuts.contribution_list.length; c_shortcuts.contribution_count++ ) {
	var contribution=c_shortcuts.contribution_list[c_shortcuts.contribution_count];
	if (c_shortcuts.history_type == "pagehistory") {
		// add "source" shortcut
		c_shortcuts.addHistoryShortcut("edit","source","mw-changeslist-source",contribution,"mw-changeslist-date" );
	} else {
		// add "edit" and "info" shortcuts
		c_shortcuts.addHistoryShortcut("edit","edit","mw-changeslist-edit",contribution,"mw-changeslist-history" );
		c_shortcuts.addHistoryShortcut("info","info","mw-changeslist-info",contribution,"mw-changeslist-history" );
	}
}

}