User:SuperMarioMan/common.js
Appearance
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
![]() | The accompanying .css page for this skin is at User:SuperMarioMan/common.css. |
/// ROLLBACK LINK TEXT SAYS ... ///
//$(document).ready(function() {$(".mw-special-Watchlist .mw-rollback-link a").text("curr-r");});
/// [[Wikipedia:Comments in Local Time]] ///
window.LocalComments = {
dateDifference: true,
dateFormat: 'dmy',
dayOfWeek: false,
dropDays: 27,
dropMonths: 12,
timeFirst: false,
twentyFourHours: false,
};
/// STREAMLINED ... ///
// WATCHLIST //
importScript('user:js/watchlist.js'); // SMART WATCHLIST // Backlink: [[user:js/watchlist.js]]
if (mw.config.get('wgCanonicalSpecialPageName') == 'Watchlist')
var unwatchLinksOnLoad = false;
// HISTORY PAGES //
if (mw.config.get('wgAction') == 'history') //add a link to call histComb.js
$(function(){
var pagehis = document.getElementById('pagehistory');
if (!pagehis) return;
var lnk = document.createElement('a');
lnk.style.marginLeft = '10px';
lnk.href = '#';
lnk.appendChild(document.createTextNode('See improved view.....'));
lnk.onclick=function(){this.parentNode.removeChild(this);importScript('User:Alex_Smotrov/histcomb.js')} // Backlink: [[User:Alex_Smotrov/histcomb.js]]
pagehis.parentNode.insertBefore(lnk, pagehis);
window.histCombLeaveComment = true //if true, keep summary on the last folded edit
window.histCombNoCollapse = true //if true, do not collapse edits on load
window.histCombMyBg = '#F0FFF0' //background on your edits (light green)
window.histCombTalk = 'talk' //string to replace 'talk'
window.histCombContrib = 'contribs' //string to replace 'contribs'
window.histCombUndo = 'undo' //string to replace 'undo'
})
/// ADDITIONS TO LEFT ///
importScript('User:Alex 21/script-redlinks.js'); // REMOVE REDLINKS // Backlink: [[User:Alex 21/script-redlinks.js]]
importScript('User:Anne drew Andrew and Drew/PageDetails.js'); // Backlink: [[User:Anne_drew_Andrew_and_Drew/PageDetails.js]]
importScript('User:Anne_drew_Andrew_and_Drew/PageDetails.js'); // Backlink: [[User:Anne_drew_Andrew_and_Drew/PageDetails.js]]
//importScript('User:Begoon/addUploadsLink.js'); // Backlink: [[User:Begoon/addUploadsLink.js]]
importScript('User:Caorongjin/wordcount.js'); // Backlink: [[User:Caorongjin/wordcount.js]]
importScript('User:Chew/scripts/HighlightQuotes.js'); // Backlink: [[User:Chew/scripts/HighlightQuotes.js]]
importScript('User:Danski454/UserLogToolbar.js'); // "LOGGED ACTIONS" & "TARGET LOGS" // Backlink: [[User:Danski454/UserLogToolbar.js]]
importScript('meta:User:Diegodlh/search-wpl.js'); // ADD WIKIPEDIA LIBRARY TO SEARCH BOX // Backlink: [[meta:User:Diegodlh/search-wpl.js]]
//importScript('User:DreamRimmer/MergeHelper.js'); // Backlink: [[User:DreamRimmer/MergeHelper.js]]
importScript('User:Epicgenius/sortcategories.js'); // Backlink: [[User:Epicgenius/sortcategories.js]]
importScript('User:Evad37/duplinks-alt.js'); // "HIGHLIGHT DUPLICATE LINKS" // Backlink: [[User:Evad37/duplinks-alt.js]]
importScript('User:Guarapiranga/WhatRedirectsHere.js'); // Backlink: [[User:Guarapiranga/WhatRedirectsHere.js]]
importScript('User:Mesidast/Curly_Quotes.js'); // Backlink: [[User:Mesidast/Curly Quotes.js]]
importScript('User:Nardog/ExpandContractions.js'); // Backlink: [[User:Nardog/ExpandContractions.js]]
importScript('User:Nardog/MoveHistory.js'); // Backlink: [[User:Nardog/MoveHistory.js]]
importScript('User:Nardog/Unpipe.js'); // Backlink: [[User:Nardog/Unpipe.js]]
//importScript('User:Phlsph7/HighlightUnreferencedPassages.js'); // Backlink: [[User:Phlsph7/HighlightUnreferencedPassages.js]]
importScript('User:Phlsph7/Readability.js'); // Backlink: [[User:Phlsph7/Readability.js]]
importScript('User:PrimeHunter/Source_links.js'); // Backlink: [[User:PrimeHunter/Source links.js]]
importScript('User:Suntooooth/flickrsearch.js'); // Backlink: [[User:Suntooooth/flickrsearch.js]]
importScript('User:Suntooooth/openversesearch.js'); // Backlink: [[User:Suntooooth/openversesearch.js]]
importScript('User:Suffusion_of_Yellow/mark-reverted.js'); // Backlink: [[User:Suffusion_of_Yellow/mark-reverted.js]]
//importScript('User:ZKang123/TitleCaseConverter.js'); // Backlink: [[User:ZKang123/TitleCaseConverter.js]]
/// ADDITIONS TO TOP ///
importScript('User:Anomie/talklink.js'); // COLOUR-CODE TALK TABS // Backlink: [[User:Anomie/talklink.js]]
importStylesheet('User:Anomie/talklink.css'); // Backlink: [[User:Anomie/talklink.css]]
//importScript('User:DannyS712/SectionRemover.js'); // Backlink: [[User:DannyS712/SectionRemover.js]]
importScript('User:Epicgenius/ArticleQuality.js'); // Backlink: [[User:Epicgenius/ArticleQuality.js]]
importScript('User:John254/mass_rollback.js'); // Backlink: [[User:John254/mass rollback.js]]
importScript('User:John254/mass rollback.js'); // Backlink: [[User:John254/mass rollback.js]]
importScript('User:Opencooper/talkCount.js'); // Backlink: [[User:Opencooper/talkCount.js]]
importScript('User:PleaseStand/highlight-comments.js'); // Backlink: [[User:PleaseStand/highlight-comments.js]]
importScript('User:Rublov/leadcaps.js'); // Backlink: [[User:Rublov/leadcaps.js]]
importScript('User:Taavi/Aligner.js'); // ADD "ALIGN TEMPLATE PARAMETERS" TAB // Backlink: [[User:Taavi/Aligner.js]]
importScript('User:Waldyrious/formatcitations.js');
importScript('User:Þjarkur/Show_number_of_active_watchers_&_monthly_views_on_every_page.js');
importScript('User:Þjarkur/Show number of active watchers & monthly views on every page.js');
// TOP LEVEL LINKS //
mw.util.addPortletLink(
'p-personal',
'/wiki/Special:PrefixIndex/User:SuperMarioMan/',
'(SUBPAGES)',
'pt-subpages',
'Your subpages',
null,
'#pt-preferences'
);
mw.util.addPortletLink(
'p-personal',
'/wiki/Special:PrefixIndex/User talk:SuperMarioMan/',
'(T)',
'pt-subpages',
'Your subpages',
null,
'#pt-preferences'
);
mw.util.addPortletLink(
'p-personal',
'/w/index.php?title=Special%3AContributions&target=SuperMarioMan&namespace=0&newOnly=1',
'(CREATED)',
'pt-contributions',
'contributions',
null,
'#pt-preferences'
);
mw.util.addPortletLink(
'p-personal',
'/wiki/Special:Log?type=block&user=SuperMarioMan',
'(B-LOG)',
'pt-mylogs',
'logs',
null,
'#pt-preferences'
);
mw.util.addPortletLink(
'p-personal',
'/wiki/Special:Log?type=delete&user=SuperMarioMan&subtype=delete',
'(D-LOG)',
'pt-mylogs',
'logs',
null,
'#pt-preferences'
);
// SEARCH OPTIONS NEXT TO ARTICLE TITLE //
// Adapted from [[User:Titodutta/scripts/SearchHelper.js]]
$(document).ready(function()
{
function getSubject()
{
let pageName = mw.config.get("wgTitle");
if (pageName.charAt(pageName.length - 1) == ")")
{
return pageName.substring(0, pageName.lastIndexOf("(") - 1);
}
else
{
return pageName;
}
}
function escapeSubject(subject)
{
return encodeURIComponent(subject.replace(/_/g, " "))
}
function createLink(url, display)
{
return $("<a>")
.attr("href", url)
.append($("<span>")
.css("font-size", "x-small")
.text(display)
);
}
function appendLinks($node, links)
{
$.each(
links,
function (index, $link)
{
$node.append(document.createTextNode(" "), $link);
}
);
}
$firstHeading = $("#firstHeading");
if(mw.config.get("wgCanonicalNamespace") == "" || mw.config.get("wgCanonicalNamespace") == "Draft")
{
let subject = getSubject();
let links = [
/*WRS from User:Sam Sailor/Scripts/WRStitle.js*/
createLink(
"https://www.google.com/custom?hl=en&cx=007734830908295939403%3Agalkqgoksq0&cof=FORID%3A13%3BAH%3Aleft%3BCX%3AWikipedia%2520Reference%2520Search&q=" + escapeSubject(subject),
"WRS"
),
createLink(
"https://news.google.com/search?q=" + escapeSubject(subject) + "+-wikipedia.org",
"Google News"
),
createLink(
"https://www.google.com/search?tbm=bks&q=" + escapeSubject(subject) + "+-wikipedia.org",
"Google Books"
),
createLink(
"https://www.jstor.org/action/doBasicSearch?Query=" + escapeSubject(subject),
"JSTOR"
),
createLink(
"http://edwardbetts.com/find_link/" + escapeSubject(subject),
"Find link"
)
];
appendLinks( $firstHeading, links );
}
if (mw.config.get("wgCanonicalNamespace") == "" && $('#t-wikibase').length )
{
let link = createLink(
$('li#t-wikibase a:first').attr('href'),
"Wikidata"
);
appendLinks( $firstHeading, [link] );
}
});
/// EVERYTHING ELSE ///
importScript('User:A455bcd9/nominations_viewer.js'); // Backlink: [[User:A455bcd9/nominations viewer.js]]
importScript('User:Amorymeltzer/logSwap.js'); // LOGPAGE "PERFORMER"-"TARGET" SWITCHING // Backlink: [[User:Amorymeltzer/logSwap.js]]
importScript('User:Amorymeltzer/unhide.js'); // AUTO-UNHIDE REV-DELETED // Backlink: [[User:Amorymeltzer/unhide.js]]
importScript('User:Animum/massdelete.js'); // Backlink: [[User:Animum/massdelete.js]]
importScript('User:Anomie/linkclassifier.js'); // COLOUR-CODE WIKILINKS // Backlink: [[User:Anomie/linkclassifier.js]]
//importScript('User:Anomie/nosubmitsummary.js'); // FORCE EDIT SUMMARY // Backlink: [[User:Anomie/nosubmitsummary.js]]
importScript('User:BrandonXLF/ListSorter.js'); // Backlink: [[User:BrandonXLF/ListSorter.js]]
importScript('User:BrandonXLF/ShowUserGender.js'); // Backlink: [[User:BrandonXLF/ShowUserGender.js]]
//importScript('User:BrandonXLF/SubpageMover.js'); // MOVE SUBPAGES // Backlink: [[User:BrandonXLF/SubpageMover.js]]
importScript('User:BrandonXLF/WatchDoc.js'); // AUTO-WATCH TEMPLATE DOC PAGES // Backlink: [[User:BrandonXLF/WatchDoc.js]]
importScript('User:Chaotic Enby/RecentUnblockHighlighter.js'); // Backlink: [[User:Chaotic Enby/RecentUnblockHighlighter.js]]
importScript('User:Chaotic_Enby/RecentUnblockHighlighter.js'); // Backlink: [[User:Chaotic Enby/RecentUnblockHighlighter.js]]
importScript('User:Danski454/w2wFinder.js'); // Backlink: [[User:Danski454/w2wFinder.js]]
importScript('meta:User:Dragoniez/Mark BLocked Global.js'); // Backlink: [[meta:User:Dragoniez/Mark_BLocked_Global.js]]
importScript('meta:User:Dragoniez/Mark_BLocked_Global.js'); // Backlink: [[meta:User:Dragoniez/Mark_BLocked_Global.js]]
importScript('User:Ebrahames/Advisor.js'); // Backlink: [[User:Ebrahames/Advisor.js]]
importScript('User:Enterprisey/diff-context.js'); // SHOW MORE LINES IN DIFFS //Backlink: [[User:Enterprisey/diff-context.js]]
importScript('User:Enterprisey/fancy-diffs.js'); // MAKE LINKS IN DIFFS CLICKABLE // Backlink: [[User:Enterprisey/fancy-diffs.js]]
importScript('User:Enterprisey/link-deleted-revs.js'); // AUTO-UNHIDE REV-DELETED // Backlink: [[User:Enterprisey/link-deleted-revs.js]]
importScript('User:Enterprisey/parent-cats.js'); // HIGHLIGHT REDUNDANT CATEGORISATION // Backlink: [[User:Enterprisey/parent-cats.js]]
importScript('User:Enterprisey/section-redir-note.js'); // "REDIRECTED FROM" IN SECTIONS // Backlink: [[User:Enterprisey/section-redir-note.js]]
importScript('User:Enterprisey/undelete-backlink.js'); // NAVIGATE BACK TO UNDELETE MAIN // Backlink: [[User:Enterprisey/undelete-backlink.js]]
importScript('User:Equazcion/CatListMainTalkLinks.js'); // Backlink: [[User:Equazcion/CatListMainTalkLinks.js]]
importScript('User:Equazcion/link_intermediate_revisions.js'); // Backlink: [[User:Equazcion/link_intermediate_revisions.js]]
importScript('User:Equazcion/link intermediate revisions.js'); // Backlink: [[User:Equazcion/link intermediate revisions.js]]
importScript('User:Erutuon/scripts/imageSize.js'); // Backlink: [[User:Erutuon/scripts/imageSize.js]]
importScript('User:Erutuon/scripts/footnoteCleanup.js'); // Backlink: [[User:Erutuon/scripts/footnoteCleanup.js]]
//importScript('User:Firefly/more-block-info.js'); // SHOW RANGEBLOCKS BETTER // Backlink: [[User:Firefly/more-block-info.js]]
importScript('User:Fred Gandt/responsiveHistoryCompare.js'); // Backlink: [[User:Fred Gandt/responsiveHistoryCompare.js]]
importScript('User:Galobtter/scripts/WatchlistLinksNewTab.js'); // FORCE NEW TABS FOR WATCHLIST
importScript('User:Gary/highlight_my_username_in_history.js'); // Backlink: [[User:Gary/highlight_my_username_in_history.js]]
importScript('User:Gary/highlight my username in history.js'); // Backlink: [[User:Gary/highlight my username in history.js]]
importScript('User:Gary/nominations_viewer.js'); // COLLAPSE FAC/FAR DISCUSSIONS // Backlink: [[User:Gary/nominations_viewer.js]]
//importScript('User:GeneralNotability/ip-ext-info.js'); // ISP INFO // Backlink: [[User:GeneralNotability/ip-ext-info.js]]
importScript('User:GhostInTheMachine/SortWhatLinksHere.js'); // Backlink: [[User:GhostInTheMachine/SortWhatLinksHere.js]]
importScript('User:Headbomb/unreliable.js'); // COLOUR-CODE UNRELIABLE SOURCES // Backlink: [[User:Headbomb/unreliable.js]]
importScript('User:Ingenuity/AbuseFilterContribs.js'); // (?)SHOW DISALLOWED EDITS IN CONTRIBS // Backlink: [[User:Ingenuity/AbuseFilterContribs.js]]
importScript('User:LFaraone/autounhide.js'); // (?)AUTO-UNHIDE REV-DELETED // Backlink: [[User:LFaraone/autounhide.js]]
importScript('User:Mattflaschen/Compare_link.js'); // MAKE "COMP. SELECTED REVS." A LINK // Backlink: [[User:Mattflaschen/Compare_link.js]]
importScript('User:Mattflaschen/Compare link.js'); // MAKE "COMP. SELECTED REVS." A LINK // Backlink: [[User:Mattflaschen/Compare_link.js]]
importScript('User:Mdaniels5757/markAdmins.js'); // USER GROUP FLAGS // Backlink: [[User:Mdaniels5757/markAdmins.js]]
importScript('User:Moonythedwarf/extra-unreliable.js'); // Backlink: [[User:Moonythedwarf/extra-unreliable.js]]
importScript('User:Mr._Stradivarius/gadgets/DiffOnly.js'); // NO PAGE CONTENT BELOW DIFFS // Backlink: [[User:Mr._Stradivarius/gadgets/DiffOnly.js]]
importScript('User:Nardog/CatChangesViewer.js'); // Backlink: [[User:Nardog/CatChangesViewer.js]]
importScript('User:Nardog/ExamineMore.js'); // Backlink: [[User:Nardog/ExamineMore.js]]
importScript('User:Nardog/RefRenamer.js'); // Backlink: [[User:Nardog/RefRenamer.js]]
importScript('User:Nardog/SmartDiff.js'); // Backlink: [[User:Nardog/SmartDiff.js]]
importScript('User:Nardog/SortCentralAuthByEditCount.js'); // Backlink: [[User:Nardog/SortCentralAuthByEditCount.js]]
//importScript('User:Nardog/VitalTopicon.js'); // Backlink: [[User:Nardog/VitalTopicon.js]]
importScript('User:Novem_Linguae/Scripts/CiteHighlighter.js'); // HIGHLIGHTING CITATIONS // Backlink: [[User:Novem_Linguae/Scripts/CiteHighlighter.js]]
importScript('User:Novem Linguae/Scripts/CiteHighlighter.js'); // Backlink: [[User:Novem Linguae/Scripts/CiteHighlighter.js]]
importScript('User:Novem_Linguae/Scripts/DetectG4G5.js'); // WARN OF RE-CREATION // Backlink: [[User:Novem Linguae/Scripts/DetectG4G5.js]]
importScript('User:Novem Linguae/Scripts/DetectG4G5.js'); // WARN OF RE-CREATION // Backlink: [[User:Novem Linguae/Scripts/DetectG4G5.js]]
importScript('User:Novem_Linguae/Scripts/UserRightsDiff.js'); // COL-CODE SPECIAL:RIGHTS // Backlink: [[User:Novem Linguae/Scripts/UserRightsDiff.js]]
importScript('User:Novem Linguae/Scripts/UserRightsDiff.js'); // COL-CODE SPECIAL:RIGHTS // Backlink: [[User:Novem Linguae/Scripts/UserRightsDiff.js]]
importScript('User:Ohconfucius/dashes.js'); // Backlink: [[User:Ohconfucius/dashes.js]]
importScript('User:Ohconfucius/script/Common Terms.js'); // Backlink: [[User:Ohconfucius/script/Common Terms.js]]
importScript('User:Ohconfucius/script/EngvarB.js'); // Backlink: [[User:Ohconfucius/script/EngvarB.js]]
importScript('User:Ohconfucius/script/formatgeneral.js'); // Backlink: [[User:Ohconfucius/script/formatgeneral.js]]
importScript('User:Ohconfucius/script/MOSNUM dates.js'); // Backlink: [[User:Ohconfucius/script/MOSNUM dates.js]]
importScript('User:Polygnotus/DuplicateReferences.js'); // Backlink: [[User:Polygnotus/DuplicateReferences.js]]
importScript('User:Pythoncoder/Scripts/voteSymbols.js'); // XFD VOTE ICONS // Backlink: [[User:Pythoncoder/Scripts/voteSymbols.js]]
importScript('User:Qwertyytrewqqwerty/DisamAssist.js'); // Backlink: [[User:Qwertyytrewqqwerty/DisamAssist.js]]
importScript('User:Remsense/Line breaks to lists.js'); // Backlink: [[User:Remsense/Line breaks to lists.js]]
importScript('User:SD0001/hide-reverted-edits.js'); // ON REVISION HISTORIES // Backlink: [[User:SD0001/hide-reverted-edits.js]]
importScript('User:SD0001/quickViewDeleted.js'); // VIEW LAST DELETED REVISION // Backlink: [[User:SD0001/quickViewDeleted.js]]
importScript('User:Suffusion_of_Yellow/filterDiff.js'); // Backlink: [[User:Suffusion of Yellow/filterDiff.js]]
importScript('User:Suffusion of Yellow/filterDiff.js'); // Backlink: [[User:Suffusion of Yellow/filterDiff.js]]
importScript('User:Suffusion_of_Yellow/filter-highlighter.js'); // COLOUR-CODE ABUSE LOG // Backlink: [[User:Suffusion of Yellow/filter-highlighter.js]]
importScript('User:Suffusion of Yellow/filter-highlighter.js'); // COLOUR-CODE ABUSE LOG // Backlink: [[User:Suffusion of Yellow/filter-highlighter.js]]
importScript('User:SuperHamster/CiteUnseen.js'); // FOOTNOTE ICONS // Backlink: [[User:SuperHamster/CiteUnseen.js]]
importScript('User:The Transhumanist/WatchlistSorter.js'); // Backlink: [[User:The Transhumanist/WatchlistSorter.js]]
importScript('User:Venkat TL/ColourContrib.js'); // Backlink: [[User:Venkat TL/ColourContrib.js]]
importScript('User:WikiMasterGhibif/capitalize.js'); // DE-CAPITALISE SELECTED // Backlink: [[User:WikiMasterGhibif/capitalize.js]]
importScript('User:Þjarkur/NeverUseMobileVersion.js'); // Backlink: [[User:Þjarkur/NeverUseMobileVersion.js]]
importScript('User:קיפודנחש/watchlistMark.js'); // BOLD WATCHLISTED PAGES // Backlink: [[User:קיפודנחש/watchlistMark.js]]
//importScript('Wikipedia:AutoEd/complete.js'); // [[Wikipedia:AutoEd]]
/// HIDE SEMI-AUTOMATED EDITS ON WATCHLIST ///
function setupHideSemiautomated() {
$( "a[title='User:SD0001/StubSorter'], a[title='Wikipedia:TW'], a[title='Wikipedia:Twinkle'], a[title='Wikipedia:HG'], a[title='Wikipedia:Huggle'], a[title='Wikipedia:RW'], a[title='Wikipedia:RedWarn'], a[title='Wikipedia:UV'], a[title='Wikipedia:Ultraviolet'], a[title='Wikipedia:AWB'], a[title='Wikipedia:AutoWikiBrowser'], a[title='Wikipedia:JWB'], a[title='User:Joeytje50/JWB'], a[title='Wikipedia:HC'], a[title='Wikipedia:HotCat'], a[title='Wikipedia:SHORTDESCHELPER'], a[title='Wikipedia:Shortdesc helper'], a[title='Wikipedia:CLEANER'], a[title='Wikipedia:WPCleaner'], a[title='Wikipedia:POPUPS'], a[title='Wikipedia:Tools/Navigation popups'], a[title='User:SD0001/GAR-helper'], a[title='Wikipedia:DisamAssist'], a[title='User:Qwertyytrewqqwerty/DisamAssist'], a[title='User:Evad37/OneClickArchiver'], a[title='User:Enterprisey/archiver'], a[title='User:Equazcion/OneClickArchiver'], a[title='Wikipedia:RATER'], a[title='User:Evad37/rater'], a[title='User:Edward/Find link'], a[title='c:Special:MyLanguage/User:JWBTH/CD'], a[title='c:Help:Cat-a-lot'], a[title='User:Evad37/rater'], a[title='Wikipedia:RATER'], a[title='Wikipedia:XFDC'], a[title='Wikipedia:XFDcloser'], a[title='User:SD0001/BDCS']" ).closest("li, tr").addClass("watchlist-semiautomated-edit");
mw.util.addPortletLink( 'p-cactions', '#', 'Hide Semiautomated', 'ca-hideSemiautomated', "Hide Semiautomated edits" );
mw.util.addPortletLink( 'p-cactions', '#', 'Show Semiautomated', 'ca-showSemiautomated', "Show Semiautomated edits" );
if ( window.semiautomatedHiddenByDefault ) {
$(".watchlist-semiautomated-edit").hide();
$('#ca-hideSemiautomated').hide();
} else {
$('#ca-showSemiautomated').hide();
}
$('#ca-hideSemiautomated').on('click', function() {
$(".watchlist-semiautomated-edit").hide();
$('#ca-showSemiautomated').show();
$('#ca-hideSemiautomated').hide();
return false;
});
$('#ca-showSemiautomated').on('click', function() {
$(".watchlist-semiautomated-edit").show();
$('#ca-showSemiautomated').hide();
$('#ca-hideSemiautomated').show();
return false;
});
}
if( mw.config.get('wgPageName') === "Special:Watchlist" ) {
$.when( mw.loader.using( ['mediawiki.util'] ), $.ready).done( setupHideSemiautomated );
}
var semiautomatedHiddenByDefault = true;
///*** titlecaseconverter.js [[User:ZKang123/TitleCaseConverter.js]] ***///
/* eslint-disable no-alert, no-console */
$( () => {
/**
* Convert titles to title case
*/
function toTitleCase( title, changeExistingCapitalization = true ) {
const isAllCaps = title.toUpperCase() === title;
if ( isAllCaps ) {
title = title.toLowerCase();
}
title = title.split( ' ' ).map( ( word, index, array ) => {
// Retain words that are already in uppercase or are special cases
if ( word.toUpperCase() === word || isSpecialCase( word ) ) {
return word;
}
// Retain capitalization for words following certain punctuation marks
if ( index > 0 && /[/;\-,]/.test( array[ index - 1 ] ) ) {
return word.charAt( 0 ).toUpperCase() + word.slice( 1 );
}
// Check for mixed capitalization
const hasMixedCase = /[a-z]/.test(word) && /[A-Z]/.test(word);
if (hasMixedCase) {
return word;
}
// If there's already a capital letter in the word, we probably don't want to change it
const hasUpperCaseLetter = /[A-Z]/.test(word);
if (!changeExistingCapitalization && hasUpperCaseLetter) {
return word;
} else if ( shouldCapitalize( word, index, array ) ) {
return word.charAt( 0 ).toUpperCase() + word.slice( 1 ).toLowerCase();
} else {
return word.toLowerCase();
}
} ).join( ' ' );
// Capitalize first letters that occur after punctuation
title = title.replace( / [^A-Za-z][a-z]/g, ( match ) => ' ' + match.slice( 1, 2 ) + match.slice( 2 ).toUpperCase() );
// Capitalize anything after a semicolon
title = title.replace( /;[a-z]/g, ( match ) => ';' + match.slice( 1 ).toUpperCase() );
// Capitalize letters mid-word that occur after hyphens or slashes
title = title.replace( /-[a-z]/g, ( match ) => '-' + match.slice( 1 ).toUpperCase() );
title = title.replace( /\/[a-z]/g, ( match ) => '/' + match.slice( 1 ).toUpperCase() );
return title;
}
/**
* Check if a word is an abbreviation or an exception
*/
function isSpecialCase( word ) {
// Define custom exceptions for abbreviations and specific titles
const exceptions = [ 'MRT', 'LTA', 'S$', 'US$', 'NASA', 'FBI', 'MP3' ]; // Add more exceptions as needed
return exceptions.includes( word ) || /^[A-Z0-9]+$/.test( word );
}
function shouldCapitalize( word, index, array ) {
const alwaysCapitalize = [ 'Me', 'It', 'His', 'If', 'Be', 'Am', 'Is', 'Are', 'Being', 'Was', 'Were', 'Been', 'During', 'Through', 'About', 'Until', 'Below', 'Under' ];
const doNotCapitalize = [ 'a', 'an', 'the', 'and', 'by', 'at', 'but', 'or', 'nor', 'for', 'yet', 'so', 'as', 'in', 'of', 'on', 'to', 'from', 'into', 'like', 'over', 'with', 'till', 'upon', 'off', 'per', 'up', 'out', 'via' ];
const punctuationMarks = [ '.', ',', ';', ':', '?', '!' ];
const isAbbr = isSpecialCase( word );
const isProperNoun = alwaysCapitalize.includes( word );
const isShortWord = doNotCapitalize.includes( word.toLowerCase() );
const isFirstOrLastWord = index === 0 || index === array.length - 1;
const isLongPreposition = word.length >= 5;
const isVerb = [ 'be', 'am', 'is', 'are', 'being', 'was', 'were', 'been' ].includes( word.toLowerCase() );
// Preserve capitalization after punctuation marks
if ( index > 0 ) {
const prevWord = array[ index - 1 ];
const lastChar = prevWord.charAt( prevWord.length - 1 );
if ( punctuationMarks.includes( lastChar ) ) {
return true;
}
}
return isAbbr || isFirstOrLastWord || isProperNoun || isLongPreposition || !isShortWord || isVerb;
}
/**
* Convert reference titles in the HTML content
*/
function convertReferenceTitles( htmlString, changeExistingCapitalization = true ) {
const citationRegex = /<ref[^>]*>.*?<\/ref>/gi;
const titleRegex = /(\|title=)([^|]+)(\|)/i;
return htmlString.replace( citationRegex, ( match ) => match.replace( titleRegex, ( titleMatch, p1, p2, p3 ) => {
const originalTitle = p2.trim();
const titleCaseTitle = toTitleCase( originalTitle, changeExistingCapitalization );
// Ensure space is retained at the end
const endingSpace = p2.endsWith(' ') ? ' ' : '';
return `${ p1 }${ titleCaseTitle }${ endingSpace }${ p3 }`;
} ) );
}
/**
* Load the script and add the sidebar links
*/
function loadTitleCaseConverter() {
// Create the first sidebar link
const sidebarLink1 = document.createElement( 'li' );
const link1 = document.createElement( 'a' );
link1.innerText = 'CRTtTC (Preserve)';
link1.href = '#';
link1.style.cssText = 'cursor: pointer; color: #0645ad;';
// Add click event listener to the first link
link1.addEventListener( 'click', ( event ) => {
event.preventDefault();
const textArea = document.querySelector( '#wpTextbox1' );
if ( textArea ) {
const summary = 'Converted reference titles to title case per [[MOS:CT]] using [[User:ZKang123/TitleCaseConverter|TitleCaseConverter]]';
textArea.value = convertReferenceTitles( textArea.value, false );
// Set default editing summary
const summaryInput = document.querySelector( '#wpSummary' );
if ( summaryInput && !summaryInput.value.trim() ) {
summaryInput.value = summary;
}
} else {
alert( 'Error: Editing area not found!' );
}
} );
sidebarLink1.appendChild( link1 );
// Create the second sidebar link
const sidebarLink2 = document.createElement( 'li' );
const link2 = document.createElement( 'a' );
link2.innerText = 'CRTtTC (Change)';
link2.href = '#';
link2.style.cssText = 'cursor: pointer; color: #0645ad;';
// Add click event listener to the second link
link2.addEventListener( 'click', ( event ) => {
event.preventDefault();
const textArea = document.querySelector( '#wpTextbox1' );
if ( textArea ) {
const summary = 'Converted reference titles to title case per [[MOS:CT]] using [[User:ZKang123/TitleCaseConverter|TitleCaseConverter]]';
textArea.value = convertReferenceTitles( textArea.value, true );
// Set default editing summary
const summaryInput = document.querySelector( '#wpSummary' );
if ( summaryInput && !summaryInput.value.trim() ) {
summaryInput.value = summary;
}
} else {
alert( 'Error: Editing area not found!' );
}
} );
sidebarLink2.appendChild( link2 );
// Add the links to the sidebar (p-tb section)
const sidebar = document.getElementById( 'p-tb' );
const ul = sidebar ? sidebar.querySelector( 'ul' ) : null;
if ( ul ) {
ul.appendChild( sidebarLink1 );
ul.appendChild( sidebarLink2 );
} else {
alert( 'Error: Sidebar section not found!' );
}
}
function runUnitTests() {
const tests = [
// normal
{
old: 'The South and West lines',
new: 'The South and West Lines'
},
{
old: 'Work on second phase of MRT system ahead of schedule',
new: 'Work on Second Phase of MRT System Ahead of Schedule'
},
{
old: 'Earlier target date for Phase II MRT',
new: 'Earlier Target Date for Phase II MRT'
},
{
old: 'MRT System to be Implemented in Eight Stages',
new: 'MRT System to Be Implemented in Eight Stages'
},
{
old: 'MRT to Bt Batok, Bt Gombak and Choa Chu Kang on Mar 10',
new: 'MRT to Bt Batok, Bt Gombak and Choa Chu Kang on Mar 10'
},
// mid-word hyphens and slashes
{
old: 'Revived, re-opened, newly appreciated',
new: 'Revived, Re-Opened, Newly Appreciated'
},
{
old: "Streetscapes/eldridge street Synagogue;a prayer-filled time capsule from the 1880's",
new: "Streetscapes/Eldridge Street Synagogue;A Prayer-Filled Time Capsule from the 1880's"
},
{
old: 'Phase 2 gets go-ahead to ensure continuity',
new: 'Phase 2 Gets Go-Ahead To Ensure Continuity'
},
// weird mid-word capitalization
{
old: 'Phase 2 gets go-ahead to build iPad',
new: 'Phase 2 Gets Go-Ahead To Build iPad'
},
{
old: 'Phase 2 gets go-ahead to build DataMall',
new: 'Phase 2 Gets Go-Ahead To Build DataMall'
},
// all caps
{
old: 'PHASE 2 GETS GO-AHEAD TO ENSURE CONTINUITY',
new: 'Phase 2 Gets Go-Ahead To Ensure Continuity'
},
// punctuation at beginning of word
{
old: 'She was "amazingly spectacular"',
new: 'She Was "Amazingly Spectacular"'
}
];
let i = 1;
let failures = 0;
for ( const test of tests ) {
const actual = toTitleCase( test.old );
if ( actual !== test.new ) {
console.log( `[Titlecaseconverter.js] Failed unit test ${ i }. Received "${ actual }" instead of "${ test.new }".` );
failures++;
}
i++;
}
if ( !failures ) {
console.log( '[Titlecaseconverter.js] All unit tests passed. Yay.' );
}
}
// Load the script when the page is ready
if ( document.readyState !== 'loading' ) {
loadTitleCaseConverter();
} else {
document.addEventListener( 'DOMContentLoaded', loadTitleCaseConverter );
}
// Put this at the top of your common.js file to run unit tests in the browser devtools console:
// window.TitleCaseConverterUnitTests = true;
if ( window.TitleCaseConverterUnitTests ) {
runUnitTests();
}
} );
///*** Highlight unreferenced passages [[User:Phlsph7/HighlightUnreferencedPassages.js]] ***///
(function(){
// finds passages that lack references and marks them
function markUnreferencedPassages(){
// stylesheet to color passages lacking references
function addStylesheet(){
const stylesheet = document.createElement('style');
stylesheet.innerHTML = `
.has-no-references, .Template-Fact {
background: LightPink;
}
`;
document.head.appendChild(stylesheet);
}
// check whether references are relevant to the element
function isEligible(element, excludedSections){
// exclude elements that are part of navboxes, sidebars, and the like
// references do not matter for them
if(hasParentClass(element, 'navbox')
|| hasParentClass(element, 'sidebar')
|| hasParentClass(element, 'infobox')
|| hasParentClass(element, 'side-box-flex')
|| hasParentClass(element, 'noprint')
|| hasParentClass(element, 'refbegin')
|| hasParentClass(element, 'gallery')
|| hasParentClass(element, 'toc')
|| hasParentClass(element, 'reflist')){
return false;
}
// exclude elements that belong to certain sections where references do not matter
const sectionName = getSectionName(element);
if(excludedSections.indexOf(sectionName) != -1){
return false;
}
return true;
}
// utility function to check whether the elements parents and grand parents have a certain class
function hasParentClass(element, className){
return element.closest('.' + className) != null;
}
// utility function to get the section name to which an element belongs
function getSectionName(element){
var mainContainerChildElement = getGrandchildOfMainContainer(element);
var sectionName = ''; // default section name, this corresponds to the lead
var previousElement = mainContainerChildElement.previousElementSibling;
// sections always start with an h2 element
// the script loops back from an element to the previous element until an h2 element is discovered
while(previousElement != null){
// check whether it is an h2 element
if(previousElement.classList.contains('mw-heading2')){
// extract the section name
sectionName = previousElement.innerText.split('[edit]').join('');
break;
}
previousElement = previousElement.previousElementSibling;
}
return sectionName;
}
// utility function: for any element, return the parent that is a grandchild of the main container
function getGrandchildOfMainContainer(element){
const mainContainer = document.getElementById('mw-content-text');
if(element.parentElement.parentElement == mainContainer){
return element;
}
else{
return getGrandchildOfMainContainer(element.parentElement);
}
}
// utility function to check whether the lead section of the article should be marked
function shouldMarkLead(){
// if it is a draft then the lead should be highlighted
var pageTitleNamespace = document.getElementsByClassName('mw-page-title-namespace')[0];
if(pageTitleNamespace != null){
if(pageTitleNamespace.innerText === 'User' || pageTitleNamespace.innerText === 'Draft'){
return true;
}
}
// if it is a stub then the lead should be highlighted
else if(document.getElementsByClassName('stub').length > 0){
return true;
}
// otherwise not
else {
return false;
}
}
// marks elements that lack references
function mark(element){
// mark elements without any reference elements
if(element.getElementsByClassName('reference').length == 0){
element.classList.add("has-no-references");
}
// mark elements with some reference elements
else{
// if the last element is not a reference then start marking it
markUntilPreviousReference(element.lastChild);
// starts from each "citation needed" tag, goes backwards and marks until it reaches a reference
var citationNeededTags = element.getElementsByClassName('Template-Fact');
for(var citationNeededTag of citationNeededTags){
markUntilPreviousReference(citationNeededTag);
}
}
}
// Function to mark unreferenced passages. It starts with one node and loops back to previous nodes until it hits a reference
function markUntilPreviousReference(childNode){
var currentNode = childNode;
while(currentNode != null){
// handle nodes that are not HTML elements
if(currentNode.classList == null){
// create a span element and classify it
var span = document.createElement('span');
span.classList.add("has-no-references");
// copy the node's text into the span element and replace the node with the span element
span.innerHTML = currentNode.data;
currentNode.parentElement.replaceChild(span, currentNode);
currentNode = span;
}
// handle nodes that are HTML elements
// if the node is a reference
else if(currentNode.classList.contains('reference')){
// check whether the node is an actual reference: they contain numbers
if(currentNode != null &&
currentNode.innerText != null &&
/[0-9]/.test(currentNode.innerText) &&
!currentNode.innerText.toLowerCase().includes('note') &&
!currentNode.innerText.toLowerCase().includes('nb')){
break;
}
// otherwise it is an explanatory footnote and not a reference
else{
currentNode.classList.add('has-no-references');
}
}
// if the node is an element but not a reference then classify it
else {
currentNode.classList.add('has-no-references');
}
// set the current node to the previous one to continue the loop
currentNode = currentNode.previousSibling;
}
}
// removes the red background from elements that were falsely highlighted
function excludeFalsePositives(){
// exclude references used in nested lists
var unreferencedElements = document.getElementsByClassName('has-no-references');
for(let unreferencedElement of unreferencedElements){
// if the element contains a reference inside then it is not unreferenced, so remove the class
if(unreferencedElement.getElementsByClassName('reference').length > 0){
unreferencedElement.classList.remove('has-no-references');
}
}
// exclude quoteboxes
unreferencedElements = document.getElementsByClassName('has-no-references');
for(let unreferencedElement of unreferencedElements){
// see if the the element is part of a quotebox that has a citation
var quoteboxParent = unreferencedElement.closest('.quotebox');
if(quoteboxParent != null && quoteboxParent.getElementsByTagName('cite').length > 0){
unreferencedElement.classList.remove('has-no-references');
}
}
// do not mark empty elements
unreferencedElements = document.getElementsByClassName('has-no-references');
for(let unreferencedElement of unreferencedElements){
if(unreferencedElement.innerHTML == "\n" || unreferencedElement.innerHTML == " \n"){
unreferencedElement.classList.remove('has-no-references');
}
}
// exclude the template {{rp}}
var referenceElements = document.getElementsByClassName('reference');
for(let referenceElement of referenceElements){
if(referenceElement.classList.contains('has-no-references')){
referenceElement.classList.remove('has-no-references');
}
}
// blockquotes often use a different reference style, so false positives need to be excluded separately
const unreferencedParagraphsInsideBlockquotes = document.querySelectorAll('blockquote > p.has-no-references');
for(var unreferencedParagraphInsideBlockquotes of unreferencedParagraphsInsideBlockquotes){
const parent = unreferencedParagraphInsideBlockquotes.parentElement;
// check whether the parent blockquote contains a citation element
if(parent.getElementsByClassName('templatequotecite').length > 0){
// if it does then the paragraph is not unreferenced
unreferencedParagraphInsideBlockquotes.classList.remove('has-no-references');
}
}
// ignore elements in the template "ombox"
let unreferencedElementsInOmboxes = document.querySelectorAll(".ombox .has-no-references");
for (let element of unreferencedElementsInOmboxes) {
element.classList.remove("has-no-references");
}
// for drafts: exclude comments
var pageTitleNamespace = document.getElementsByClassName('mw-page-title-namespace')[0];
if(pageTitleNamespace != null){
if(pageTitleNamespace.innerText === 'User' || pageTitleNamespace.innerText === 'Draft'){
let unreferencedComments = document.querySelectorAll(".has-no-references:has(.localcomments)");
for (let unreferencedComment of unreferencedComments) {
unreferencedComment.classList.remove("has-no-references");
}
}
}
}
addStylesheet();
// all paragraphs and list entries should have references
const paragraphs = document.getElementById('mw-content-text').getElementsByTagName('p');
const listEntries = document.getElementById('mw-content-text').getElementsByTagName('li');
const elements = Array.from(paragraphs).concat(Array.from(listEntries));
// these sections are not checked for references
var excludedSections = ['Plot', 'Plots', 'Plot summary', 'Plot synopsis', 'Synopsis', 'Storylines', 'Further reading', 'See also', 'External links', 'References', 'Bibliography', 'Notes', 'Selected publications', 'Selected works', 'Cited sources', 'Sources', 'Footnotes'];
// dedice whether the lead should be checked for references
if(!shouldMarkLead()){
excludedSections.push('');
}
for(var element of elements){
// check whether the element should be excluded
if(isEligible(element, excludedSections)){
// mark the element if it lacks references
mark(element);
}
}
excludeFalsePositives();
}
// restrict script to mainspace, userspace, and draftspace
var namespaceNumber = mw.config.get('wgNamespaceNumber');
if (namespaceNumber === 0 || namespaceNumber === 2 || namespaceNumber === 118) {
// add a link to the toolbox
$.when(mw.loader.using('mediawiki.util'), $.ready).then(function (){
var portletlink = mw.util.addPortletLink('p-tb', '#', 'Unrefd parts');
// run the main function when the link is clicked
portletlink.onclick = function(e) {
e.preventDefault();
markUnreferencedPassages();
const unreferencedElements = document.getElementsByClassName('has-no-references');
//mw.notify(`${unreferencedElements.length} elements were highlighted`);
mw.notify('Highlighting finished.');
};
});
}
if (namespaceNumber === 0 || namespaceNumber === 118) {
if(typeof highlightUnreferencedPassagesAutomatic != 'undefined' && highlightUnreferencedPassagesAutomatic == true){
markUnreferencedPassages();
}
}
})();