User:Danhash/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:Danhash/common.css. |
// <nowiki>
/* Disabled 5/16/17 due to error with mw.util; figure out another way to do this
$( function() { //red links don't go to edit mode
var $alinks = mw.util.$content.find( 'a.new' )
.each( function(i, aa){
aa.href = aa.href.replace(/[?&]action=edit/, '')
})
})
*/
/*
==Misc. script imports==
*/
// [[User:Lupin/popups.js]]
//popupStructure //'original', 'fancy', 'fancy2', 'menus', 'shortmenus', 'lite', 'nostalgia'
//var popupModifier = ; //'' (default), 'ctrl', 'shift', 'alt', 'meta'
//simplePopups = ; //true, false //No data will be downloaded and the popups will just consist of a list of links.
//popupActionsMenu //true, false //When using menus, you can either have the title link in the popup generating a menu (if this is set to false) or a separate "actions" menu (if this is set to true, the default).
// var popupFixRedirs = 'true';
// var popupRedlinkRemoval = 'true';
// var popupFixDabs = 'true';
// var popupDelay = 0.7;
// var popupHideDelay = 0.2;
// var popupStructure = 'menus';
// importScript('User:Lupin/popups.js');
// Popups.js is now maintained as a gadget; configuration options for the gadget is available here: https://en.wikipedia.org/wiki/Wikipedia:Tools/Navigation_popups#Options
/* disabled 5/16/17 for troubleshooting
window.popupFixRedirs = 'true';
window.popupRedlinkRemoval = 'true';
window.popupFixDabs = 'true';
window.popupDelay = 0.7;
window.popupHideDelay = 0.2;
window.popupStructure = 'menus';
//importScript('User:Yair rand/ReferenceTooltips.js'); //shows refs in tooltips on mouseover
//importStylesheet('User:Yair rand/ReferenceTooltips.css'); //stylesheet for ^
//importScript('User:Odie5533/SnipManager.user.js'); //seems useful, but annoying since it messes up wikEd's fullscreen mode
// add hidetopcontrib; shows "show/hide top" under contributions
userHideAllSubsequent=true;
//importScript('User:Markhurd/hidetopcontrib.js'); //Linkback: [[User:Markhurd/hidetopcontrib.js]]
// end hidetopcontrib
//importScript('User:AzaToth/twinkle.js'); //install twinkle; keep this, duh //Linkback: [[User:AzaToth/twinkle.js]]
//importScript('User:Bility/copySectionLink.js'); //pilcrows when mousing over headings; keep it //Linkback: [[User:Bility/copySectionLink.js]]
*/
/* disabled on 5/16/17 for troubleshooting
$(function () { //add new pages link to toolbar
mw.util.addPortletLink(
"p-navigation", // toolbox portlet
"https://en.wikipedia.org/wiki/Special:NewPages",
"New Pages" // link label
)});
$(function () { //add new pages link to toolbar
mw.util.addPortletLink(
"p-navigation", // toolbox portlet
"https://en.wikipedia.org/wiki/Special:PendingChanges",
"Pending Changes" // link label
)});
$(function () { //add toolbar link for editing this page
mw.util.addPortletLink(
"p-tb", // toolbox portlet
"https://en.wikipedia.org/w/index.php?title=User:Danhash/common.js&action=edit",
"edit common.js" // link label
)});
*/
/*
==[[User:Js]] stuff==
*/
/* disabled 5/16/17 for troubleshooting
if( wgPageName == 'User:Js' ) importScript('user:js/tools.js') //Linkback: [[user:js/tools.js]]
if (wgCanonicalSpecialPageName == 'Watchlist') { //cool watchlist features that i use
//importScript('user:js/watchlist.js'); //Linkback: [[user:js/watchlist.js]]
}
*/
/*
==wikEd==
*/
/* Migrating wikEd to [[meta:User:Danhash/global.js]] (see [[user:danhash/Interwiki/JS and CSS config]])
//importScript('User:Cacycle/wikEd.js'); //i use this and it's awesome, duh //Linkback: [[User:Cacycle/wikEd.js]]
var wikEdConfig = {};
wikEdConfig.showSourceButton = true;
wikEdConfig.regExTypoFix = true;
wikEdConfig.showTableModeButton = true;
wikEdConfig.showUsingButton = true;
wikEdConfig.summaryUsing = '(using [[User:Cacycle/wikEd|wikEd]])';
*/
/*
===Custom functions===
*/
/* disabled on 5/16/17; will need to migrate some of these settings to my global.js
wikEd = {
config: {
// define custom buttons [id, class, Tool tip, image url, width, height, alt text, onClick with parameters]
button: {
100: ['WrapInCode', 'wikEdButton', 'Wrap selection in <code>...</code>', 'http://upload.wikimedia.org/wikipedia/commons/6/67/WikEd_logo.png', '16', '16', 'DIV', 'WikEdEditButton(this, this.id, null, WrapInCode);' ],
101: ['WrapInNowiki', 'wikEdButton', 'Wrap selection in <nowiki>...</nowiki>', 'https://upload.wikimedia.org/wikipedia/commons/5/5a/WikEd_nowiki.png', '16', '16', 'Test', 'WikEdEditButton(this, this.id, null, WrapInNowiki);' ]
},
// define custom button bars [id outer, class outer, id inner, class inner, height, grip title, button numbers]
buttonBar: {
'custom2': ['wikEdButtonBarCustom1', 'wikEdButtonBarCustom1', 'wikEdButtonsCustom1', 'wikEdButtonsCustom1', 44, 'My custom buttons', [100, 'br', 101] ]
}
}
}
*/
// define the function which is called upon clicking the custom button
// this example code adds or removes div tags around the selected text
/* disabled 5/16/17 for troubleshooting
function WrapInCode(obj) {
// select the appropriate text change target (whole, selection, cursor, focusWord, focusLine, selectionWord, or selectionLine)
// focus... is the text under the cursor; ...Word and ...Line extend the target to the start/end of the word or line
WikEdGetText(obj, 'selection, cursor');
if (obj.selection.plain != '') {
obj.changed = obj.selection;
} else {
obj.changed = obj.cursor;
}
// make the changes to the plain target text
if ( /<code>([\s\S]*?)<\/code>/i.test(obj.changed.plain) ) {
// remove the previously added formatting
obj.changed.plain = obj.changed.plain.replace(/<code>([\s\S]*?)<\/code>/gi, '$1');
} else {
// add the text formatting
obj.changed.plain = '<code>' + obj.changed.plain + '</code>';
// Move spaces outside
obj.changed.plain = obj.changed.plain.replace(/(<code>)( *)([\s\S]*?)( *)(<\/code>)/, '$2$1$3$5$4');
}
// keep the changed text selected, needed to remove the formatting with a second custom button click
obj.changed.keepSel = true;
return;
}
function WrapInNowiki(obj) {
// select the appropriate text change target (whole, selection, cursor, focusWord, focusLine, selectionWord, or selectionLine)
// focus... is the text under the cursor; ...Word and ...Line extend the target to the start/end of the word or line
WikEdGetText(obj, 'selection, cursor');
if (obj.selection.plain != '') {
obj.changed = obj.selection;
} else {
obj.changed = obj.cursor;
}
// make the changes to the plain target text
if ( /<nowiki>([\s\S]*?)<\/nowiki>/i.test(obj.changed.plain) ) {
// remove the previously added formatting
obj.changed.plain = obj.changed.plain.replace(/<nowiki>([\s\S]*?)<\/nowiki>/gi, '$1');
} else {
// add the text formatting
obj.changed.plain = '<nowiki>' + obj.changed.plain + '</nowiki>';
// Move spaces outside
obj.changed.plain = obj.changed.plain.replace(/(<nowiki>)( *)([\s\S]*?)( *)(<\/nowiki>)/, '$2$1$3$5$4');
}
// keep the changed text selected, needed to remove the formatting with a second custom button click
obj.changed.keepSel = true;
return;
}
*/
/*
===Default edit summaries===
*/
/* Migrating wikEd to [[meta:User:Danhash/global.js]] (see [[user:danhash/Interwiki/JS and CSS config]])
wikEdConfig.comboPresetOptions = {};
wikEdConfig.comboPresetOptions.summary = [
'TEMPLATES',
'+{{[[Template:XXXX|XXXX]]}}',
' ',
'DASHES/QUOTES/REFS/MOS:',
'[[WP:REFPUNC|reference punctuation]]',
'[[MOS:LQ|logical quotation]]',
'single to double [[WP:MOS#Quotation marks|quotation marks]]',
'curly to straight [[WP:MOS#Quotation marks|quotation marks]] and apostrophes',
'fix [[WP:MOS#Quotation marks|quotation marks]]',
'move quotation marks outside of links',
'move quotation marks outside of bold',
'fix [[MOS:DASH|dashes]]',
'punctuation',
'commas',
'rewrite [[WP:MOS#Contractions|contractions]]',
'remove "™" and "®" per [[Wikipedia:Manual of Style/Trademarks]]',
'{{[[WP:Citation Needed|citation needed]]}}',
'rm [[WP:WEASEL|weasel words]]',
' ',
'TALK PAGES:',
'reply',
' ',
'REMOVE/REVERT:',
'revert unexplained removal',
'revert [[WP:V|unsourced]]',
'revert [[WP:ELNO|external links]]',
' ',
'LEAD',
'rm "illegally"',
'bold abbreviation in lead',
' ',
'GENERAL CLEANUP/EDITING:',
'rm [[WP:WHITE|whitespace]]',
'rm [[WP:V|unsourced]]',
'rm [[WP:V|unsourced]] material which appears to be [[WP:NOR|original research]]',
'rm spam',
'rm [[WP:REDNOT|red links]]',
'copyedit',
'update links',
'fix links',
'rm unsourced sentence',
'rm entire [[WP:V|unsourced]] paragraph',
' ',
'TECHNICAL:',
'fix [[Wikipedia:Double redirects|double redirect]] after page move',
'update [[WP:DEFAULTSORT|DEFAULTSORT]]',
'update [[WP:HATNOTE|hatnote]] to use {{[[Template:About|about]]}}',
'update [[WP:HATNOTE|hatnote]] to use {{[[Template:For|for]]}}',
'update [[WP:HATNOTE|hatnote]] to use {{[[Template:Redirect|redirect]]}}',
'Cleaned up using [[WP:AutoEd|AutoEd]]',
'[[Wikipedia:RegExTypoFix|RegExTypoFix]] using [[User:Cacycle/wikEd|wikEd]]',
'(using [[User:Cacycle/wikEd|wikEd]])',
'edit wikEd RegEx defaults',
'edit wikEd edit summaries',
' ',
'IMAGE TEMPLATES:',
'+{{ShouldBePNG}}',
'+{{BadJPEG}}'
];
===Find/replace regex presets===
wikEdConfig.comboPresetOptions.find = [
'(“|”|″)', //match curly double quotes
"(‘|’|′|`)", //match curly single quotes/apostrophes
"(‘|’|′|'|`)", //match all single quotes/apostrophes
'(‘|’|′|\'|`)((.){1,15})(‘|’|′|\'|`)', //match apostrophes and curly single quotes
'(“|”|″)((.){1,15})(“|”|″)', //match curly double quotes
'(\\.|,)"', //match period or comma before end of quote
'\'',
'-',
' – ',
'(™|®)'
];
wikEdConfig.comboPresetOptions.replace = [
'\\"$2\\"', //use in conjunction with the quote matching above to replace "wrong" quotes with "correct" quotes
'"$1', //use in conjunction with the above RegEx to match period or comma before end of quote; this moves the period of comma to after the ending quotation mark
'\n',
'"',
'\'',
'–'
];
*/
/* END wikEd */
/*
== AutoEd ==
=== AutoEd modules ===
*/
//i use this
/* disabled 5/16/17 for troubleshooting
//importScript('Wikipedia:AutoEd/core.js'); //Linkback: [[Wikipedia:AutoEd/core.js]]
//importScript('Wikipedia:AutoEd/fullwidth.js'); //Linkback: [[Wikipedia:AutoEd/fullwidth.js]]
//importScript('Wikipedia:AutoEd/headlines.js'); //Linkback: [[Wikipedia:AutoEd/headlines.js]]
//importScript('Wikipedia:AutoEd/htmltowikitext.js'); //Linkback: [[Wikipedia:AutoEd/htmltowikitext.js]]
//importScript('Wikipedia:AutoEd/isbn.js'); //Linkback: [[Wikipedia:AutoEd/isbn.js]]
//importScript('Wikipedia:AutoEd/links.js'); //Linkback: [[Wikipedia:AutoEd/links.js]]
//importScript('Wikipedia:AutoEd/templates.js'); //Linkback: [[Wikipedia:AutoEd/templates.js]]
//importScript('Wikipedia:AutoEd/unicodecontrolchars.js'); //Linkback: [[Wikipedia:AutoEd/unicodecontrolchars.js]]
//importScript('Wikipedia:AutoEd/unicodehex.js'); //Linkback: [[Wikipedia:AutoEd/unicodehex.js]]
//importScript('Wikipedia:AutoEd/unicodify.js'); //Linkback: [[Wikipedia:AutoEd/unicodify.js]]
//importScript('Wikipedia:AutoEd/wikilinks.js'); //Linkback: [[Wikipedia:AutoEd/wikilinks.js]]
//importScript('Wikipedia:AutoEd/dashes.js');
//importScript("User:GregU/dashes.js") //Linkback: [[User:GregU/dashes.js]]
//importScript('Wikipedia:AutoEd/extrabreaks.js');
//importScript('Wikipedia:AutoEd/tablestowikitext.js');
//importScript('Wikipedia:AutoEd/whitespace.js');
*/
/*
=== AutoEd functions ===
*/
/* disabled 5/16/17 for troubleshooting
function autoEdFunctions() { //Activates individual modules when "auto ed" tab is clicked
var txt = document.editform.wpTextbox1;
txt.value = autoEdFullwidth(txt.value);
txt.value = autoEdHeadlines(txt.value);
txt.value = autoEdHTMLtoWikitext(txt.value);
txt.value = autoEdISBN(txt.value);
txt.value = autoEdLinks(txt.value);
txt.value = autoEdTemplates(txt.value);
txt.value = autoEdUnicodeControlChars(txt.value);
txt.value = autoEdUnicodeHex(txt.value);
txt.value = autoEdUnicodify(txt.value);
txt.value = autoEdWikilinks(txt.value);
txt.value = autoEdDashes(txt.value);
//txt.value = autoEdExtraBreaks(txt.value);
//txt.value = autoEdTablestoWikitext(txt.value);
//txt.value = autoEdWhitespace(txt.value);
}
autoEdClick = false; //for compatibility with wikEd
*/
/* END AutoEd */
/*
==Gary King scripts==
[[User:Gary King/Scripts]]
*/
/* disabled 5/16/17 for troubleshooting
//importScript('User:Gary King/comments in local time.js'); //[[User:Gary King/comments in local time.js]]; a little buggy but very useful //Linkback: [[User:Gary King/comments in local time.js]]
//importScript('User:Gary_King/comment_highlighter.js'); //useful; Highlights recent comments yellow, while your own comments are highlighted in blue. (Requires User:Gary King/comments in local time.js for now). //Linkback: [[User:Gary_King/comment_highlighter.js]]
*/
//importScript('User:Gary_King/prose_size.js'); //[[User:Gary_King/prose_size.js]]
/* END Gary King scripts */
// </nowiki>