User:Kaiserwilliam/common.js

/** * Regex menu framework adds a sidebar menu of user-defined scripts. * @see https://github.com/Pathoschild/Wikimedia-contrib#readme * @update-token */ $.getScript('//meta.wikimedia.org/w/index.php?title=User:Pathoschild/Scripts/Regex_menu_framework.js&action=raw&ctype=text/javascript');

// importScript('User:Inductiveload/InlinePagenums.js'); importScript('User:Inductiveload/Metadata_form.js'); importScript('User:Inductiveload/Roman numerals.js'); importScript('User:Inductiveload/Running header.js'); importScript('User:Inductiveload/Visibility.js'); // MOST OF THIS IS COPIED STRAIGHT FROM USER:BILLINGHURST/MONOBOOK.JS popupFixDabs=true; /* No idea what this does */ popupAdminLinks=true; /* I'm guessing this is admin specific */ // == THIS AUTOFILLS SOME OF THE PARAMETERS IN THE AUTHOR HEADER == importScript('User:Phe/Author fill.js'); // == THIS SEARCHES FOR WORKS ABOUT THE AUTHOR IN CERTAIN REFERENCES BUT IF THERE AREN'T ANY IT JUST ADDS AN EDIT SUMMARY - IT IS IMPLEMENTED BELOW == importScript('User:Phe/Works about.js'); //JSconfig.keys['HotCatEditBoxWidth'] = 80; //sets width of HotCat gadget // == IMPORT SOME SCRIPTS - MAINLY TWINKLE - FROM ENWIKI == mw.loader.load('https://en.wikipedia.org/w/index.php?title=User:AzaToth/morebits.js&action=raw&ctype=text/javascript'); mw.loader.load('https://en.wikipedia.org/w/index.php?title=User:AzaToth/twinklefluff.js&action=raw&ctype=text/javascript'); mw.loader.load('https://en.wikipedia.org/w/index.php?title=User:AzaToth/twinklediff.js&action=raw&ctype=text/javascript'); mw.loader.load('https://en.wikipedia.org/w/index.php?title=User:AzaToth/twinkleprotect.js&action=raw&ctype=text/javascript'); mw.loader.load('https://en.wikipedia.org/w/index.php?title=User:AzaToth/twinkleunlink.js&action=raw&ctype=text/javascript'); mw.loader.load('https://en.wikipedia.org/w/index.php?title=User:AzaToth/twinklebatchdelete.js&action=raw&ctype=text/javascript'); mw.loader.load('https://en.wikipedia.org/w/index.php?title=User:AzaToth/twinklebatchprotect.js&action=raw&ctype=text/javascript'); mw.loader.load('https://en.wikipedia.org/w/index.php?title=User:AzaToth/twinklebatchundelete.js&action=raw&ctype=text/javascript'); // == IMPORT FRIENDLY FROM ENWIKI == mw.loader.load('https://en.wikipedia.org/w/index.php?title=User:Ioeth/friendlytag.js&action=raw&ctype=text/javascript'); mw.loader.load('https://en.wikipedia.org/w/index.php?title=User:Ioeth/friendlytalkback.js&action=raw&ctype=text/javascript'); // === FRIENDLY SETTINGS === if( typeof( FriendlyConfig ) == 'undefined' ) FriendlyConfig = {}; // DO NOT REMOVE THIS LINE - ALL FRIENDLY SETTINGS AFTER THIS FriendlyConfig.groupByDefault			=	true; /*FriendlyConfig.insertHeadings			=	true;*/ FriendlyConfig.insertSignature			=	true; /*FriendlyConfig.insertUsername			=	true;*/ FriendlyConfig.markTaggedPagesAsMinor		=	true; FriendlyConfig.markTaggedPagesAsPatrolled	=	true; FriendlyConfig.markTalkbackAsMinor		=	true; FriendlyConfig.markWelcomesAsMinor		=	false; FriendlyConfig.maskTemplateInSummary		=	true; FriendlyConfig.quickWelcomeMode		=	"semiauto"; FriendlyConfig.quickWelcomeTemplate		=	"Welcome"; FriendlyConfig.summaryAd			=	" using Friendly"; FriendlyConfig.talkbackHeading			=	"== Talkback =="; FriendlyConfig.topWelcomes			=	true; FriendlyConfig.watchTaggedPages		=	false; FriendlyConfig.watchWelcomes			=	false; FriendlyConfig.welcomeHeading			=	"== Welcome =="; FriendlyConfig.customWelcomeList	=	[ {			label: ': Welcome for account holders', value: 'CustomWelcome' }, {			label: ': Welcome for IP addresses', value: 'subst:Welcomeip' } /*,		{			label: ': Custom welcome template description (now includes parameters!)', value: 'CustomWelcome|para=value' }*/ ]; // == GLOBAL PARAMETERS == /*most from User:Billinghurst/monobook.js - those I don't need I'm keeping as models*/ /*set some global parameters for selection */ //preset variables, REMINDER THAT THESE HAVE UNDERSCORE WORD SEPARATORS for location.href var isUserNS = (-1 != location.href.indexOf("User_talk:")); var isPageNS = (-1 != location.href.indexOf("Page:")); var isAuthorNS = (-1 !== location.href.indexOf("Author:")); /*why double ==?*/ var isAgrippa = (-1 != location.href.indexOf("Page:[\w\_]+Occult_Philosophy")); /*not sure if I'll use this but it's a long project*/ var isIndianBio = (-1 != location.href.indexOf("Page:The_Indian_Biographical_Dictionary.djvu/"));/*model only*/ var isIrishBio = (-1 != location.href.indexOf("Page:A_Compendium_of_Irish_Biography"));/*model only*/ var isBiography = (-1 != location.href.indexOf("Page:[\w\_]+Biography")); var isDNB00 = (-1 != location.href.indexOf("DNB00")); var isMainspace = (-1 == location.href.search(/title=(Talk|User|User_talk|Wikisource|Wikisource_talk|File|File_talk|Mediawiki|Mediawiki_talk|Template|Template_talk|Help|Help_talk|Category|Category_talk|Portal|Portal_talk|Author|Author_talk|Page|Page_talk|Index):/)); // == SIDEBAR SCRIPTS /*I prefer the cleanness of a portlet like en:User:Jsimlo/shortcuts, I wonder if that's possible*/ == //Pathoschild's regex /*where is this imported?*/ function rmflinks { // === CALLS FOR USE IN ALL NAMESPACES === regexTool('clean up','cleanup'); regexTool('Indent', 'Indent'); // === CALLS FOR USE IN THE PAGESPACE === if (isIndianBio) { regexTool('IndianBio','IndianBio'); }    if (isBiography) { regexTool('Anchor','anchor'); regexTool('internal nslink','nslink'); regexTool('djvu pagelink','djvupagelink'); } // === CALLS THAT IMPLEMENT ONLY IN THE APPROPRIATE NAMESPACE === if (isMainspace) { regexTool('DefSort Subpage','defsortsubpage'); if (isDNB00) { regexTool('DNBset','DNBset'); } 	       regexTool('override transl','otranslator'); /* I don't see any script for this to call */ regexTool('remove TQ','rmTextQual'); regexTool('','similar'); regexTool('Ch.prev & next','PrevNext'); regexTool('Pages','tag_pages'); /* I can't tell what this does */ } else /*why "else" here?*/ if (isPageNS) { regexTool('Header', 'RunningHeader'); regexTool('Footer','RunningFooter'); regexTool('nop','nop'); /* not within the if for pagespace but only functions there */ regexTool('s to ſ', 'grab_s'); regexTool('ſ to ', 'long_s_replace'); regexTool('ct to ƈt', 'grab_ct'); regexTool('ƈt to ', 'ct_replace'); }     if (isUserNS) { regexTool('welcome','welcome'); regexTool('welcomeip & test','weliptest'); regexTool('welcomeip','welcomeip'); regexTool('toggle in Page:', 'HeaderToggle'); }    if (isAuthorNS) { regexTool('Works about', 'works_about'); } // === THESE SCRIPTS BELOW APPEAR TO HAVE NO CALLS === //trans //und2ital //chapcase //endword /*this has been replaced with RunningFooter*/ //smallrefs_rep //header_center } // == SCRIPTS == //USER TALK namespace // welcome applies // weliptest subst applies // welcomeip subst // HeaderToggle subst: User:Billinghurst/HeaderToggle which tells how to toggle header in Page: function welcome { editbox.value = editbox.value + ' ' + ''; editreason.value = editreason.value + 'welcome'; } function weliptest { editbox.value = editbox.value + ' ' + '\n'; editreason.value = editreason.value + 'welcome & test'; } function welcomeip { editbox.value = editbox.value + ' ' + ''; editreason.value = editreason.value + 'welcome'; } function HeaderToggle { editbox.value = editbox.value + ''; } //MAIN namespace // DNBset - replaces with // rmTextQual removes // trans replaces translator with override_translator // und2ital converts underlines to italics (PG adaption) // similar adds above header // PrevNext from section, wikis Chapter -1/+1 to Prev/Next // tag_pages applies using #tag and index  fromsection tosection take // defsortsubpage function DNBset { editbox.value = editbox.value.replace(/\{\{header[^\}]+\}\}\n/, ''); } function rmTextQual { editbox.value = editbox.value.replace(/\{\{TextQuality\|\d{2,3}%\}\}/, ''); } function trans { editbox.value = editbox.value.replace(/ translator\w+\=/, ' override_translator = '); } function und2ital { editbox.value = editbox.value.replace(/\_/g, '\'\''); } function similar { editbox.value = editbox.value.replace(/\{\{header/g, '\n{{header'); editreason.value = editreason.value + ''; } function PrevNext { var newtitle = parseInt(wgTitle.replace(/^.*\/Chapter (\d+)$/,'$1'))-1; var headerprevious = '../Chapter '+newtitle+'/'; var newtitle = parseInt(wgTitle.replace(/^.*\/Chapter (\d+)$/,'$1'))+1; var headernext = '../Chapter '+newtitle+'/'; editbox.value = editbox.value.replace(/\| previous  \= \n \| next       \= /, '| previous   \= ' + headerprevious +'\n \| next       \= ' + headernext ); } //subst: #tag and some fields function tag_pages { var selStart = editbox.selectionStart; var selEnd = editbox.selectionEnd; var pre = editbox.value.substring(selStart, selEnd); // var pages= ''; var pages= ''; editbox.value = editbox.value.substring(0, selStart) + pages + editbox.value.substring(selEnd); editbox.focus; editbox.setSelectionRange(selStart+post.length, selStart+post.length); } function defsortsubpage { editbox.value = editbox.value + '' } //ALL NAMESPACE USE // cleanup - all sorts of text cleaning from OCR // chapcase - Chapter uc to sc // nop - nop, though it puts it at the bottom of editbox, so only useful in Page: function cleanup { var editbox = document.getElementsByName('wpTextbox1')[0]; // Digitized by Google (kill) editbox.value = editbox.value.replace(/Digitized[\s\n]+by[\s\n]+Google/, ''); // remove trailing spaces at the end of each line editbox.value = editbox.value.replace(/ +\n/g, '\n'); // remove trailing whitespace preceding a hard line break editbox.value = editbox.value.replace(/ +/g, ' '); // remove trailing whitespace at the end of page text editbox.value = editbox.value.replace(/\s+$/g, ''); // remove trailing spaces at the end of refs editbox.value = editbox.value.replace(/ +<\/ref>/g, ' '); // remove trailing spaces at the end of template calls editbox.value = editbox.value.replace(/ +}}/g, '}}'); // convert double-hyphen to mdash (avoiding breaking HTML comment syntax) editbox.value = editbox.value.replace(/([^\!])--([^>])/g, '$1—$2'); // remove spacing around mdash, but only if it has spaces on both sides // (we don't want to remove the trailing space from "...as follows:— ",       // bearing in mind that the space will already be gone if at end of line). editbox.value = editbox.value.replace(/ +— +/g, '—'); // join words that are hyphenated across a line break // (but leave "|-" table syntax alone) editbox.value = editbox.value.replace(/([^\|])-\n/g, '$1'); // stuff to do only if the page doesn't contain a tag: if (-1 == editbox.value.indexOf(" ")) { // remove single line breaks; preserve multiple. // but not if there's a tag, template or table syntax either side of the line break editbox.value = editbox.value.replace(/([^>}\n])\n([^<{\|\n])/g, '$1 $2'); // collapse sequences of spaces into a single space editbox.value = editbox.value.replace(/ +/g, ' '); }       // remove unwanted spaces around punctuation marks editbox.value = editbox.value.replace(/ ([;:\?!,])/g, '$1'); //OCR fixes // convert i9 to 19, etc.	editbox.value = editbox.value.replace(/[il]([0-9])/g, '1$1'); // "the", "them", "their", etcetera editbox.value = editbox.value.replace(/tlie/g, 'the'); // "U" -> "ll" when preceded by a lowercase letter. editbox.value = editbox.value.replace(/([a-z])U/g, '$1ll'); } // convert uc to sc function chapcase { editbox.value = editbox.value.replace(/CHAPTER/g, ''); } // nop at bottom of editbox function nop { editbox.value += '\n'; } //SPECIFIC TO Page: namespace // IndianBio - cleanup for Page:The Indian Biographical Dictionary.djv // anchor - applies // RunningHeader - puts in to headerbox // endword - puts into footerbox // smallrefs_rep - puts into footerbox /* Page:The Indian Biographical Dictionary.djvu tools */ function IndianBio { var headerbox = document.getElementsByName('wpHeaderTextbox')[0]; headerbox.value = headerbox.value + 'INDIAN BIOGRAPHICAL DICTIONARY, 1915.\n\n'; cleanup; editbox.value = editbox.value.replace(/([\n\s])([bmsd]\.)/g, '$1\'\'$2\'\'') .replace (/([\n\s])(Address|Clubs?|educ|Publications|Recreations)\:/g, '$1\'\'$2\'\':') .replace (/CLE\.?/g, 'C.I.E.'); // VU -> VII; followed by U in the middle of a word -> ll       editbox.value = editbox.value.replace(/VU/g, 'VII') .replace(/(\w)U(\w)/, '$1ll$2'); } /* Page:A Compendium of Irish Biography tools */ function anchor { var selStart = editbox.selectionStart; var selEnd = editbox.selectionEnd; var pre = editbox.value.substring(selStart, selEnd); var anch = ''; editbox.value = editbox.value.substring(0, selStart) + anch + editbox.value.substring(selEnd); editbox.focus; editbox.setSelectionRange(selStart+post.length, selStart+post.length); } //adds template 'DJVU page link' function djvupagelink { var selStart = editbox.selectionStart; var selEnd = editbox.selectionEnd; var pre = editbox.value.substring(selStart, selEnd); if (isIrishBio) {var work = 24;} else {var work = '';} var DJVU = ''; editbox.value = editbox.value.substring(0, selStart) + DJVU + editbox.value.substring(selEnd); editbox.focus; editbox.setSelectionRange(selStart+post.length, selStart+post.length); } //set to internal namespace link, set specifically for subpage xref function nslink { var selStart = editbox.selectionStart; var selEnd = editbox.selectionEnd; var pre = editbox.value.substring(selStart, selEnd); var nslink = ''; editbox.value = editbox.value.substring(0, selStart) + nslink + editbox.value.substring(selEnd); editbox.focus; editbox.setSelectionRange(selStart+post.length, selStart+post.length); } //PAGE NAMESPACE headerbox or footerbox function RunningHeader { var headerbox = document.getElementsByName('wpHeaderTextbox')[0]; headerbox.value = headerbox.value + ''; } //*Footerbox app; for archaic books where the first word on the next page is placed at bottom function RunningFooter { var footerbox = document.getElementsByName('wpFooterTextbox')[0]; footerbox.value = footerbox.value.replace(/(\<\/div>)/, '$1'); } //Indent function Indent { var headerbox = document.getElementsByName('wpHeaderTextbox')[0]; headerbox.value = headerbox.value.replace(/(\)/g, ' '); } function smallrefs_rep { var footerbox = document.getElementsByName('wpFooterTextbox')[0]; footerbox.value = footerbox.value.replace(/(\)/,''); } function header_center { var headerbox = document.getElementsByName('wpHeaderTextbox')[0]; headerbox.value = headerbox.value + ''; } function grab_s { editbox.value = editbox.value.replace(/s(?![\Wf])/g, 'ſ'); } function long_s_replace { editbox.value = editbox.value.replace(/ſ/g, ''); } function grab_ct { editbox.value = editbox.value.replace(/ct/g, 'ƈt'); } function ct_replace { editbox.value = editbox.value.replace(/ƈt/g, ''); } // == CUSTOM TABS == // === Adds a tab for soft redirects below "move" === /* Soft redirect */ /* See WS:SCRIPTS; adds "soft redirect" tab in Firefox. */      document.write(' '); // === TWINKLE TABS === /* Twinkle and Friendly add several tabs under a "TW" dropdown, they are controlled by imported scripts */ // == CUSTOM BUTTONS == /*Import from subpage*/ importScript('User:Doug/custombuttons.js'); //