User:SoledadKabocha/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:SoledadKabocha/common.css. |
var dt = new Date( );
var dtH = dt.getHours( );
var dtM = dt.getMinutes( );
var dtUDm = dt.getUTCDate( );
var dtUDw = dt.getUTCDay( );
// XXX: There are still more mw.config.get calls to replace with this
// XXX: Should use a time delay after each attempt, but that would need Promises (?)
function safelyGetMwConfig( confName ) {
var result = null, maxAttempts = 19;
for ( var i = 0; i < maxAttempts; i++ ) {
try {
result = mw.config.get( confName );
} catch ( ex ) {
/* XXX TODO */
}
if ( result !== null ) { return result; }
}
return result;
}
var zzSentinel = dt.getSeconds( ) + Math.random( );
var zzAction = safelyGetMwConfig( 'wgAction' );
if ( typeof zzAction !== 'string' ) zzAction = zzSentinel + '';
var zzArticleId = safelyGetMwConfig( 'wgArticleId' );
if ( typeof zzArticleId !== 'number' ) zzArticleId = zzSentinel;
var zzUserEditCount = safelyGetMwConfig( 'wgUserEditCount' );
if ( typeof zzUserEditCount !== 'number' ) zzUserEditCount = zzSentinel;
var zzPageName = safelyGetMwConfig( 'wgPageName' );
if ( typeof zzPageName !== 'string' ) zzPageName = zzSentinel + '';
var zzNamespaceNumber = safelyGetMwConfig( 'wgNamespaceNumber' );
if ( typeof zzNamespaceNumber !== 'number' ) zzNamespaceNumber = zzSentinel;
var zzPageContentModel = safelyGetMwConfig( 'wgPageContentModel' );
if ( typeof zzPageContentModel !== 'string' ) zzPageContentModel = zzSentinel + '';
// XXX: this is the syntax used in linkclassifier, but
// [[mw:RL/DEV#Client-side (dynamically)]] says to use mw.loader.using(...).done(...) instead?
// NB: jsfnPortletLink, below, isn't actually called til well after this point (and its definition).
// Similarly for hideTwinklePortlet defined below (XXX reconsider)
function hideTwinklePortlet( ) {
mw.util.addCSS( '#p-twinkle, a[href*="twinklerevert="], div[id^="tw-revert"] { display:none; }' );
}
mw.loader.using( [ 'mediawiki.util' ], function ( ) {
if ( typeof mw.util.jsMessage === 'function' ) {
var origMUJsM = mw.util.jsMessage;
mw.util.jsMessage = function( myMsg, clss ) {
if ( myMsg === 'Could not load twinkleoptions.js' && clss === undefined ) {
hideTwinklePortlet( );
}
origMUJsM( myMsg, clss );
}
}
mw.util.addPortletLink( 'p-tb', '#replaceMe', '__________', 'ca-dummysep' );
mw.util.addCSS( '#p-logo:hover { filter:blur(' + ( Math.random( ) + Math.random( ) ) + 'px); }' );
});
var zzRealBackendResponseTime = safelyGetMwConfig( 'wgBackendResponseTime' );
// TODO: are there legitimate reasons this can be null? is it really that unlikely for backend to respond within 1ms?
var zzSentinelBackendResponseTime = 1 /*10 * ( 6000 + Math.floor( Math.random( ) * 24000 ) ) + 9*/;
var zzBackendResponseTime = zzSentinelBackendResponseTime;
if (
typeof zzRealBackendResponseTime === 'number' &&
zzRealBackendResponseTime >= 0 &&
zzRealBackendResponseTime === Math.ceil( zzRealBackendResponseTime )
) {
zzBackendResponseTime = zzRealBackendResponseTime;
}
//TODO: create a separate version which supports the 5th arg of addPortletLink (title text)
function jsfnPortletLink( container, myFunc, dispName, liId, myArg ) {
var hasMwNotifyLoaded = ( typeof mw.notify === 'function' );
var hasMwUtilLoaded = ( mw.util && typeof mw.util.addPortletLink === 'function' );
if ( !hasMwUtilLoaded ) return; // uh oh, need to do the rewrite and clean up our use of .using
var typ = typeof myFunc;
if ( typ !== 'function' ) {
var errStr = 'myFunc was a(n) ' + typ + ', but we needed a function';
if ( hasMwNotifyLoaded ) {
mw.notify(
$( '<strong class="error">[jsfnPortletLink] ' + errStr + '</strong>' ),
{ autoHide: false }
);
}
throw new TypeError( errStr );
}
/*if ( hasMwNotifyLoaded ) {
// TEMP DEBUG
mw.notify( 'jsfnPortletLink is trying...' );
}*/
try {
var plnk = mw.util.addPortletLink(
container, '#' + Math.random( ), dispName, liId
);
$( plnk ).click( function ( e ) {
e.preventDefault( );
//TODO: expand to handle multiple args
myFunc.call( this, myArg );
});
} catch ( ex ) {
if ( hasMwNotifyLoaded ) {
mw.notify(
$(
'<strong class="error">[jsfnPortletLink] ' +
'Something went wrong adding the link; swallowing error to preserve other functionality' +
'</strong>'
),
{ autoHide: false }
);
}
}
}
//using gadget
LocalComments = {
dateDifference: true,
dateFormat: 'dmy',
timeFirst: true,
twentyFourHours: true,
dayOfWeek: true,
dropDays: 121,
dropMonths: 30
};
//$( '#searchInput' ).attr( 'placeholder', '' );
var isActionEditing = /it$/.test( zzAction );
function printSHStatus( ) {
mw.util.jsMessage( '<samp>TOut: ' + syntaxHighlighterConfig.timeout + 'ms<br />'
+ 'Best: ' + window.syntaxHlBestTime + 'ms<br />'
+ 'Wrst: ' + window.syntaxHlWorstTime + 'ms<br />'
+ 'UpLf: ' + window.syntaxHlTimeoutUpdatesLeft + '<br />'
+ 'SpTl: ' + syntaxHighlighterConfig.spikeTolerance + 'ms<br />'
+ 'NumS: ' + window.syntaxHlNumSpikesTolerated + '<br />'
+ 'Abrt: ' + window.syntaxHlAborted + '<br />'
+ 'dPRF: ' + window.syntaxHlDetectedResistFingerprintingPref + '</samp>' );
}
syntaxHighlighterConfig = {
adaptiveTiming: true,
timeoutCallback: function( thresh, actual ) {
mw.util.jsMessage( 'syntax highlighter abort ' + actual + 'ms>' + thresh + 'ms<br />'
+ '<samp>Best: ' + window.syntaxHlBestTime + 'ms<br />'
+ 'Wrst: ' + window.syntaxHlWorstTime + 'ms<br />'
+ 'UpLf: ' + window.syntaxHlTimeoutUpdatesLeft + '<br />'
+ 'SpTl: ' + syntaxHighlighterConfig.spikeTolerance + 'ms<br />'
+ 'NumS: ' + window.syntaxHlNumSpikesTolerated + '<br />'
+ 'Abrt: ' + window.syntaxHlAborted + '<br />'
+ 'dPRF: ' + window.syntaxHlDetectedResistFingerprintingPref + '</samp>' );
}
}
if ( Math.random( ) < 5/8 ) {
syntaxHighlighterConfig.timeoutMsg = '';
}
else {
syntaxHighlighterConfig.languageOverride = 'es';
}
function checkBadPipeTrick( ) {
var edsumbox = $( '#wpSummary' );
if ( !edsumbox || edsumbox.length === 0 ) return;
var edsumboxtext = edsumbox.val( );
if ( typeof edsumboxtext !== 'string' ) return;
if ( /\[\[.+\|\]\]/.test( edsumboxtext ) ) {
mw.util.addCSS( '.mw-summary-preview{color:red;}' )
mw.util.addCSS( '.mw-summary-preview a{text-decoration:line-through;}' )
mw.util.addCSS( '.mw-summary-preview a:not(.new){color:red;}' )
mw.notify( $(
'<span class="badpipewarn">Attempted pipe trick in edit summary — does NOT work</span>'
) );
}
else if ( /^Undid revision \d+ by \[\[Special:Contributions\/SoledadKabocha\|SoledadKabocha\]\] \(\[\[User talk:SoledadKabocha\|talk\]\]\)$/.test( edsumboxtext ) ) {
//DIRTY HACK - move this elsewhere - scope of zz vars??
if ( safelyGetMwConfig( 'wgAction' ) === 'edit' ) { //that is, not 'submit'
edsumbox.val( edsumboxtext.replace( 'SoledadKabocha]] ([[User talk:SoledadKabocha|talk]])', 'self]]: ' ) );
}
}
var editbox = $( '#wpTextbox1' );
if ( !editbox || editbox.length === 0 ) return;
var editboxtext = editbox.val( );
if ( typeof editboxtext !== 'string' ) return;
if ( /<ref( name="[^<>]+")?>[^<>]*\[\[[^<>]+\|\]\][^<>]*<\/ref>/.test( editboxtext ) ) {
mw.notify( $(
'<span class="badpipewarn">Attempted pipe trick in footnote — does NOT work</span>'
) );
}
if ( editboxtext.indexOf( '``' + '`' ) !== -1 ) {
mw.notify( $(
'<span class="badpipewarn">Shift key not pressed hard enough when signing?</span>'
) );
// XXX: should have a separate class name
}
// XXX: the two if statements are only for visual sanity...make sure to indent nicely when rewriting
// TODO: random probability?
/*if ( zzNamespaceNumber === 0 && ( /^#redirect/i.test( editboxtext ) || /\{\{[Rr](edirect category|cat) shell/.test( editboxtext ) ) ) {
if ( window.location.search.indexOf( "oldid=" ) === -1 && window.location.search.indexOf( "undoafter=" ) === -1 && edsumboxtext.indexOf( "Undid revision" ) === -1 ) {
mw.notify( 'STOP - You are supposed to be on partial wikibreak', { autoHide: false } );
}
// else log something?
}*/
}
var isEditingSection = ( window.location.search.indexOf( "section=" ) !== -1 );
var isLongArticle = /^(List_of_(Internet_top-level_domain|TCP_and_UDP_port_number)s|Wikipedia:Database_reports\/)$/.test( zzPageName ) && zzAction !== 'history' /*&& !isEditingSection // hmmm */;
var isViewingANArchive = ( /^Wikipedia:.+noticeboard\/.*Archive\d+$/.test( zzPageName ) && zzAction === 'view' );
if ( isActionEditing ) {
importScript('User:SoledadKabocha/enterInSummaryPreviews.js');
//window.BetterCancelAddSectionAnchor = true; //FIXME: now always falsely warns due to DOM structure changes; investigate this
importScript('User:SoledadKabocha/betterCancelLite.js');
window.aBBWarnInitially = ( zzAction === 'submit' ); // XXX: needs rethink
if ( zzPageContentModel === 'wikitext' ) {
importScript( 'User:SoledadKabocha/syntax highlighter experimental.js' );
if ( syntaxHighlighterConfig.adaptiveTiming ) {
jsfnPortletLink( 'p-cactions', printSHStatus, 'synHs', 'ca-syntaxhighlightdbg' );
}
importScript('User:SoledadKabocha/cleanArrows.js');
window.aBBWarnInitially = ( window.aBBWarnInitially && (zzNamespaceNumber % 2) === 0 );
}
importScript('User:SoledadKabocha/antiBracketBot.js');
/*if ( document.getElementById( 'mw-missingsummary' ) ) {
var jqMSWarn = $( '#mw-missingsummary .mbox-text' );
var MSWarnStr = jqMSWarn.html( );
if ( MSWarnStr ) jqMSWarn.html( MSWarnStr.replace( 'Edit summaries help other users understand the intention of your edits. ', '' ) );
}*/
checkBadPipeTrick( );
}
else {
if ( zzNamespaceNumber >= 0 && zzAction === 'view' ) {
if ( zzPageName === 'Wikipedia:Lamest_edit_wars' ) {
$( '#bodyContent div' ).removeClass( 'plainlinks' );
}
else if ( zzPageName.indexOf( 'Wikipedia:Wikipedia_Signpost/20' ) === 0 ) {
$( '#bodyContent div:not(.NavContent):not([style*="font-family"])' ).removeClass( 'plainlinks' );
}
}
// toggle uncat display (potentially) every 20 minutes,
// with the boundary of the 20-min intervals shifted by +/- 1 min
// based on something slowly varying (i.e. my edit count)
var dtUnitMapping = [
Math.min( dtH + dtUDw, dtUDm ),
dtH,
Math.max( dtH + dtUDw, dtUDm )
];
var dtMfudged = dtM;
if ( zzUserEditCount % 4 === 0 ) {
dtMfudged--;
if ( dtMfudged < 0 ) dtMfudged = 59;
}
else if ( zzUserEditCount % 4 === 2 ) {
dtMfudged++;
if ( dtMfudged > 59 ) dtMfudged = 0;
}
var mess = zzArticleId || document.URL.charCodeAt( -1 );
var thirdOfHrIndex = Math.floor( dtMfudged / 20 );
// Math.floor guarantees that the result, if a finite number, is an integer
// The typeof might be unnecessary, but can never be too sure...
if ( typeof thirdOfHrIndex !== 'number' || !isFinite( thirdOfHrIndex ) || thirdOfHrIndex < 0 || thirdOfHrIndex > 2 ) {
mw.notify(
'common.js (rediruncategorized): We found that it is the ' + thirdOfHrIndex + '-th third of the hour, which is invalid!',
{ autoHide: false }
);
thirdOfHrIndex = 0;
}
mess += dtUnitMapping[ thirdOfHrIndex ];
mess %= 2;
if ( mess === 0 ) { //formerly [[User:SoledadKabocha/rediruncategorized.css]]
mw.util.addCSS( 'A.redirect.redir-uncategorized:not(.userlink):hover,' +
'A.mw-redirect.redir-uncategorized:not(.userlink):hover'+
'{color:red; background-image:linear-gradient(to top, white, #ffed59, white);}' );
}
//window.BAWarnInSiteSub = false;
//window.BAWarnAsJsMessage = false;
//window.BAAutofillSearch = !isViewingANArchive;
//importScript('User:SoledadKabocha/badAnchorWarning.js');
}
window.CLRNNoAutoStart = window.CLRNstripAnchors = true;
importScript('User:SoledadKabocha/contentLinkRedirectNo.js');
function addRedirectNoWrapper( ) {
if ( typeof addRedirectNo === 'function' ) {
addRedirectNo( );
var myPortletLink = $( '#ca-contentredirectno' );
if ( myPortletLink ) myPortletLink.remove( );
}
}
jsfnPortletLink( 'p-tb', addRedirectNoWrapper, 'Add redirect=no', 'ca-contentredirectno' );
function editboxSpacesToTabs( tabSize ) {
if ( typeof tabSize !== 'number' || tabSize !== Math.ceil( tabSize ) || tabSize < 2 ) return;
var editbox = $( '#wpTextbox1' );
if ( !editbox || editbox.length === 0 ) return;
var editboxtext = editbox.val( );
if ( typeof editboxtext !== 'string' ) return;
var maxLevel = 15; // arbitrary
var exemplar = '';
for ( var i = 0; i < maxLevel; i++ ) {
exemplar += ' ';
}
var levelSeen = 0;
for ( var curLevel = maxLevel; curLevel > 0; curLevel-- ) {
var re = new RegExp( '^ {' + ( tabSize * curLevel ) + '}', 'gm' );
var neweditboxtext = editboxtext.replace( re, exemplar );
if ( neweditboxtext !== editboxtext && levelSeen === 0 ) {
levelSeen = curLevel;
}
editboxtext = neweditboxtext;
exemplar = exemplar.slice( 0, -1 );
}
mw.notify( 'Highest tab level: ' + levelSeen );
editbox.val( editboxtext );
}
if ( isActionEditing ) {
jsfnPortletLink( 'p-cactions', editboxSpacesToTabs, 'Sp→T(2)', 'ca-sptotab-2', 2 );
jsfnPortletLink( 'p-cactions', editboxSpacesToTabs, 'Sp→T(4)', 'ca-sptotab-4', 4 );
jsfnPortletLink( 'p-cactions', editboxSpacesToTabs, 'Sp→T(8)', 'ca-sptotab-8', 8 );
}
//window.checkLinksToCitations = ( zzNamespaceNumber !== 10 && !( zzNamespaceNumber % 2 === 1 && zzPageName.indexOf('/') === -1 ) );
//if ( !isEditingSection ) { importScript('User:SoledadKabocha/HarvErrors.js'); }
function checkHarv( ) {
// just to make sure nothing is calling this
mw.notify( 'checkHarv unavailable because HarvErrors.js no longer in use' );
}
const FALLBACK_LAG = 999999;
function lagCheckerCallback( r, sts, xhr ) {
if ( typeof afterLagCheck !== 'function' ) {
mw.notify(
'common.js: lagCheckerCallback could not find afterLagCheck! ' +
'This means we did not load completely!',
{ autoHide: false }
);
return;
}
if ( !r ) {
afterLagCheck( FALLBACK_LAG ); return;
}
if ( !r.query ) {
afterLagCheck( FALLBACK_LAG ); return;
}
if ( !r.query.dbrepllag ) {
afterLagCheck( FALLBACK_LAG ); return;
}
if ( !r.query.dbrepllag[0] ) {
afterLagCheck( FALLBACK_LAG ); return;
}
if ( r.query.dbrepllag[0]['lag'] === undefined ) {
afterLagCheck( FALLBACK_LAG ); return;
}
var lagSeconds = parseInt( r.query.dbrepllag[0]['lag'] );
if ( !isFinite( lagSeconds ) ) lagSeconds = FALLBACK_LAG;
afterLagCheck( lagSeconds );
}
var lcq = {
format:'json',
action:'query',
meta:'siteinfo',
siprop:'dbrepllag'
};
$.ajax( {
url:mw.util.wikiScript('api'),
dataType:'json',
type:'POST',
data:lcq,
rawdata:lcq,
success:lagCheckerCallback,
error:function( xhr, textStatus, errorThrown ) {
if ( typeof afterLagCheck === 'function' ) {
afterLagCheck( FALLBACK_LAG );
}
}
} );
/* *** BEGIN afterLagCheck *** */ function afterLagCheck( lagSeconds ) {
var totalSrvLoad = lagSeconds * 1000 + zzBackendResponseTime;
var numLinksSentinel = 9999; // arbitrary num > loadThresh
var numLinks = numLinksSentinel;
try {
numLinks = $( '#bodyContent a[href^="/w"]' ).length;
} catch ( ex ) {
/* XXX TODO */
}
if ( typeof numLinks !== 'number' ) { numLinks = numLinksSentinel; }
var dummysepHash = '#lag=' + lagSeconds + '...brt=' + zzBackendResponseTime + '...nlnk=' + numLinks;
// todo, make conditional on ns etc.?
var loadThresh = 8096;
var llHypotSq = totalSrvLoad * totalSrvLoad + numLinks * numLinks;
// "dblagging" name is a historical artifact
var dblagging = llHypotSq > ( loadThresh * loadThresh );
if ( dblagging ) {
var lagWarnStr = 'Pausing scripts due to server load and/or long page';
var lagWarnAutohide = true;
//var lagCheckEncounteredFatalError = false;
if ( lagSeconds === FALLBACK_LAG ) {
lagWarnStr = 'Problem checking db lag - pausing scripts';
lagWarnAutohide = ( zzNamespaceNumber === 0 && zzAction === 'view' );
//temporarily moved here (hmm)
if ( typeof hideTwinklePortlet === 'function' ) { hideTwinklePortlet( ); }
}
else if ( zzBackendResponseTime === zzSentinelBackendResponseTime ) {
lagWarnStr = 'Got ' + zzRealBackendResponseTime +
' for wgBackendResponseTime, which is not a nonneg. int! ';/* +
'Should never happen! Second try ';*/
/*var brtSecondTry = mw.config.get( 'wgBackendResponseTime' );
if (
typeof brtSecondTry === 'number' &&
brtSecondTry >= 0 &&
brtSecondTry === Math.ceil( brtSecondTry )
) {
zzBackendResponseTime = brtSecondTry;
lagWarnStr += 'seems to have worked, though.';
//If we failed to get one config var, we probably failed to get others too (XXX really?)
if ( zzAction === zzSentinel + '' ) lagWarnStr += ' [A!]';
if ( zzNamespaceNumber === zzSentinel ) lagWarnStr += ' [NN!]';
if ( zzPageName === zzSentinel + '' ) lagWarnStr += ' [PN!]';
if ( zzPageContentModel === zzSentinel + '' ) lagWarnStr += ' [PCM!]';
//safer to re-get these unconditionally?
zzAction = mw.config.get( 'wgAction' );
zzNamespaceNumber = mw.config.get( 'wgNamespaceNumber' );
zzPageName = mw.config.get( 'wgPageName' );
zzPageContentModel = mw.config.get( 'wgPageContentModel' );
lagWarnAutohide = ( zzNamespaceNumber === 0 && zzAction === 'view' );
totalSrvLoad = lagSeconds * 1000 + zzBackendResponseTime;
dblagging = ( totalSrvLoad * totalSrvLoad + numLinks * numLinks ) > ( loadThresh * loadThresh );
}
else {
lagWarnStr += 'failed too! PANIC!! ABORTING - PLEASE RELOAD!!';
lagWarnAutohide = false;
lagCheckEncounteredFatalError = true;
}
dummysepHash = dummysepHash.replace(
'...realbrt=REPLACEME',
'...realbrt=' + zzRealBackendResponseTime + '...retrybrt=' + brtSecondTry
);*/
}
mw.notify( lagWarnStr, { autoHide: lagWarnAutohide } );
/*if ( lagCheckEncounteredFatalError === true ) {
if ( typeof hideTwinklePortlet === 'function' ) { hideTwinklePortlet( ); }
throw new Error( 'mw.config.get failed repeatedly in user script - should never happen unless browser is mishandling timeouts' );
}*/
} else {
window.talklinkDisableRedirection = true;
window.talklinkShowRedirectTarget = true;
if ( zzNamespaceNumber >= 0 && (zzNamespaceNumber % 2) === 0 && /^.i/.test( zzAction ) ) importScript('User:SoledadKabocha/talklink.js'); //mod.from User:Anomie/talklink.js
}
//dummysepHash = dummysepHash.replace( '...realbrt=REPLACEME', '' );
$( '#ca-dummysep a' ).attr( 'href', dummysepHash );
var isPageSandbox = ( zzPageName === 'Wikipedia:Sandbox' || zzPageName === 'Wikipedia_talk:Sandbox' || /^Template(_talk)?:X[1-9](\/(doc|testcases))?$/.test( zzPageName ) || zzPageName === 'Template:Template_sandbox' || zzPageName.toLowerCase().indexOf( '/sandbox' ) !== -1 );
window.LinkClassifierAutohideFatalErrors = zzNamespaceNumber === 0 && zzAction === 'view';
window.LinkClassifierNoApihighlimits = true;
window.LinkClassifierOnDemand = dblagging || zzPageName === 'Special:LintErrors' || zzPageName === 'Wikipedia:Featured_articles' || (
zzNamespaceNumber === 6 &&
zzAction === 'view' &&
!!document.getElementById( 'mw-indicator-commons-icon' )
);
window.LinkClassifierSkipDraftDetection = dblagging || ( isActionEditing && ( totalSrvLoad >= 1490 || zzNamespaceNumber === 0 ) ) || isLongArticle || isViewingANArchive || totalSrvLoad >= 4490 || zzPageName === 'Wikipedia:Database_reports/Stale_drafts';
window.LinkClassifierOnDemandText = 'LnkClssfr';
window.LinkClassifierOnDemandLoc = 'p-tb';
window.LinkClassifierRedirTitleAppend = true;
//window.LinkClassifierUninterruptible = !isActionEditing;
window.LinkClassifierStatusSel = '#content';
window.LinkClassifierIgnoreRedirectedFrom = window.LinkClassifierSkipDraftDetection;
window.LinkClassifierSlowDownMin = Math.round( Math.random( ) ); // i.e. 0 or 1
if ( window.LinkClassifierIgnoreRedirectedFrom ) { window.LinkClassifierSlowDownMin++; }
if ( llHypotSq >= ( 253 * 253 ) ) { window.LinkClassifierSlowDownMin++; }
if ( lagSeconds > 0 ) { window.LinkClassifierSlowDownMin++; }
window.LinkClassifierSlowDownMax = Math.min( Math.ceil( Math.sqrt( totalSrvLoad ) * Math.log1p( totalSrvLoad ) ), 2200 );
window.LinkClassifierSlowDownMax = Math.max( window.LinkClassifierSlowDownMax, 24 );
window.mbNoAutoStart = window.LinkClassifierOnDemand || isActionEditing || isViewingANArchive;
window.mbLocalContribsName = ['Contributions', 'Contribs', 'Block', 'CentralAuth', 'DeletedContributions', 'EmailUser', 'Emailuser', 'ListFiles', 'Nuke', 'UserRights'];
window.mbOnDemandLinkText = 'Userlink info';
window.mbOnDemandLinkLoc = 'p-tb';
window.mbLoadingOpacity = 0.25;
window.mbTempStyle = 'opacity:0.63; font-style:normal; text-decoration:line-through';
window.mbTemp2Style = 'opacity:0.8; font-style:italic; text-decoration:line-through; text-shadow:#F83A33 0px 0px 1px';
window.mbIndefStyle = 'font-style:italic; text-decoration:line-through; text-shadow:#F61000 0px 0px 2px';
window.mbLongThreshold = 11.5*24*60*60*1000;
window.mbLongThreshIsRemainingTime = true;
window.mbPseudoIndefThreshold = 1.25*365.2425*24*60*60*1000;
window.mbShowRegDateRel = true;
window.mbShowYears = true;
window.mbEnableWhenEditing = ( zzNamespaceNumber === 4 || (zzNamespaceNumber % 2) === 1 || isPageSandbox || zzPageName.indexOf( 'User:SoledadKabocha/' ) === 0 ) && zzPageContentModel === 'wikitext' && !dblagging;
window.mbEnableOnMainspaceDiff = true;
window.mbReplaceUserRedLinksWithContribs = true;
window.mbShibbocuridleet = true;
window.LinkClassifierChainedFunc = function ( ) {
if ( typeof markBlocked === 'function' ) { markBlocked( ); }
else { importScript( 'User:SoledadKabocha/markBlockedPlus.js' ); }
}
importScript('User:SoledadKabocha/linkclassifier2.js');
function isEditReasonableForBLR( ) {
var editbox = $( '#wpTextbox1' );
if ( !editbox || editbox.length === 0 ) return false;
var editboxtext = editbox.val( );
if ( typeof editboxtext !== 'string' ) return false;
if ( zzPageContentModel === 'wikitext' ) {
if ( /\{\| *class="/.test( editboxtext ) ) return false;
if ( /(<font .*color="|style=".*color:)/.test( editboxtext ) ) return false;
if ( editboxtext.indexOf( '<syntaxh' + 'ighlight ' ) !== -1 ) return false;
// fall through to length test
}
else { return false; }
return ( editboxtext.length >= 768 && editboxtext.length < 15000 );
}
window.beelineReaderAutoColor = isActionEditing && zzNamespaceNumber > 0 && zzNamespaceNumber !== 10 && !isPageSandbox && isEditReasonableForBLR( );
importScript('User:SoledadKabocha/beelineReader.js');
if ( isActionEditing ) {
ajaxPreviewFull = ( zzNamespaceNumber === 0 || isPageSandbox ) && !isEditingSection && window.location.search.indexOf( 'undoafter=' ) === -1 && window.location.search.indexOf( 'oldid=' ) === -1;
window.ajaxPreviewExec = function(previewArea) {
window.LinkClassifierChainedFuncArg = previewArea;
LinkClassifier.onDemand();
if ( window.syntaxHlAborted === true ) {
mw.notify( $(
// This can be triggered more than once per editing session (if we ajax-preview more than once).
// Therefore, use a class rather than an ID.
'<span class="syntaxhighlighter-notrunning">' +
'WARNING: Syntax highlighter underperformed and gave up. You <b>must</b> do a <b>non-ajax</b> preview to resume highlighting syntax.' +
'</span>'
) );
}
checkBadPipeTrick();
if ( typeof checkEditBrackets === 'function' ) { checkEditBrackets(); }
if ( typeof checkHarv === 'function' ) { checkHarv(); }
if ( !document.getElementById( 'ca-contentredirectno' ) ) {
jsfnPortletLink( 'p-tb', addRedirectNoWrapper, 'Add redirect=no', 'ca-contentredirectno' );
}
$( '#editnotice-area' ).addClass( 'editnotice-ajaxpreviewed' );
$( '.mw-warning-with-logexcerpt' ).addClass( 'editnotice-ajaxpreviewed' );
$( '#revision-info' ).addClass( 'editnotice-ajaxpreviewed' );
//in principle this could be done for #editingold, but I'm already hiding it unconditionally in css
$( '.limitreport' ).addClass( 'limitreport-ajaxpreviewed' );
var forceSHDbgPrb = ( zzNamespaceNumber === 0 ? 0.5 : 0.2 );
if ( zzPageContentModel === 'wikitext' && typeof printSHStatus === 'function' ) {
if ( Math.random( ) < forceSHDbgPrb && window.syntaxHlAborted !== true ) {
printSHStatus( );
}
}
}
//ajaxPreviewPos = 'bottom'; //FIXME
window.ajaxPreviewMsg = {
emptydiff: '<span id="ajax-preview-emptydiff">No changes</span>',
difftip: '<span id="ajax-preview-tipmsg">SHIFT-click the button to show changes compared to this old version</span>',
diff2old: '<span id="ajax-preview-tipmsg">Comparison to old version</span>',
viewtip: '<span id="ajax-preview-tipmsg">SHIFT-click the button to update categories; interwikis may disappear</span>'
};
importScript('User:SoledadKabocha/ajaxPreview.js');
}
setTimeout( importScript, 4 + Math.ceil( Math.random( ) * 76 ), 'User:SoledadKabocha/common-junk.js' );
}/* *** END afterLagCheck *** */