User:He7d3r/Tools.js
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
/*jshint browser: true, camelcase: true, curly: true, eqeqeq: true, immed: true, latedef: true, newcap: true, noarg: true, noempty: true, nonew: true, quotmark: true, undef: true, unused: true, strict: true, laxbreak: true, trailing: true, maxlen: 120, evil: true, onevar: true */
/*global jQuery, mediaWiki */
( function ( mw, $ ) {
'use strict';
mw.log( 'Started global.js.' );
mw.loader.using( [ 'mediawiki.util', 'jquery.cookie' ], function(){
var enableMyScripts = $.cookie( 'enable-my-scripts' ) !== 'false',
// enableLocalScripts,
/*
// Modul: revisionjumper.js Ermöglicht das Springen in Diffs und Permalinks
// getoldid = true,
disabledisplayonpermalink = true,
disabledisplayondiff = true,
displayonhistory = true,
displayonview = false,
*/
isEditOrSubmit = $.inArray( mw.config.get( 'wgAction' ), [ 'edit', 'submit' ]) !== -1;
// isPtWb = $.inArray( mw.config.get( 'wgSiteName' ), [ 'Wikilivros', 'WikiLocal' ]) !== -1;
$( function () {
var $portlet,
label = {
'true': 'Disable my scripts',
'false': 'Enable my scripts'
},
cookieOptions = {
expires: 1,
path: '/'
};
if ( $('#ca-toggle-js').length ) {
return;
}
$portlet = $( mw.util.addPortletLink(
'p-tb',
'#',
label[ enableMyScripts ],
'ca-toggle-js',
'Turn my scripts on or off and reload the page'
) );
$portlet.click( function (e) {
// prevent '#' from appearing in URL bar
e.preventDefault();
if ( enableMyScripts ) {
$.cookie( 'enable-my-scripts', 'false', cookieOptions );
} else {
$.removeCookie( 'enable-my-scripts', cookieOptions );
}
// Reloads the document (from the cache)
document.___location.reload( false );
} );
} );
if ( enableMyScripts ) {
/* Begin user scripts */
var wget = function ( wikilink ) {
var host,
// '[[proj:lang:Ns:Page.js]]' --> 'proj:lang:Ns:Page.js'
link = wikilink.replace( /^\[\[|\]\]$/g, '' ),
// 'proj:lang:Ns:Page.js' --> [ 'proj', 'lang', 'Ns', 'Page.js' ]
parts = link.split( ':' ),
ctype = link.substr(-4) === '.css' ? 'text/css' : 'text/javascript',
page = parts.slice(-2).join( ':' ),
proj = {
// language projects
w: 'wikipedia',
b: 'wikibooks',
s: 'wikisource',
wikt: 'wiktionary',
v: 'wikiversity',
voy: 'wikivoyage',
q: 'wikiquote',
// multilingual projects
c: 'commons.wikimedia',
mw: 'www.mediawiki',
d: 'www.wikidata',
m: 'meta.wikimedia',
species: 'species.wikimedia'
};
if ( /^(https?:)?\/\//.test( link ) ) {
if ( ctype === 'text/css' ) {
mw.loader.load( link, ctype );
} else {
$.ajax(
link,
{
dataType:'script',
cache:true,
timeout: 5000
}
);
}
return;
} else if ( parts.length > 3 ) {
// [[proj:lang:Ns:Page.js]]
host = parts[1] + '.' + proj[ parts[0] ] + '.org';
} else if ( parts.length === 3 ) {
// [[proj:Ns:Page.js]]
host = proj[ parts[0] ] + '.org';
} else {
mw.log.error( 'wget > ' + link + ' not found' );
}
mw.loader.load(
'https://' + host + '/w/index.php?title=' +
mw.util.wikiUrlencode( page ) + '&action=raw&ctype=' + ctype,
ctype
);
};
/*jshint camelcase:false */
window.EditTools_initial_subset = 1;
/*jshint camelcase:true */
// Decodificação de URLs
window.urlDecoderKey = 'c'; // Accesskey
window.urlDecoderIntLinks = true; // Also decode existing [[internal links]] in selected text
// Show warnings in a dismissable bar at the top of page.
var $el = $( '#my-log' );
if( !$el.length ){
$el = $( '<ul id="my-log"></ul>' )
.css( {
background: '#ff6',
margin: 0,
padding: '8px',
width: '100%',
'max-height': '250px',
'overflow-y': 'scroll'
} );
}
$el.dblclick( function () { $el.empty().detach(); } );
mw.trackSubscribe( 'mw.deprecate', function ( topic, err ) {
$el.append(
$( '<li></li>' )
.text( JSON.stringify( err ) )
)
.prependTo( '#mw-content-text' );
} );
mw.trackSubscribe( 'global.error', function ( topic, err ) {
$el.prepend(
$( '<li></li>' )
.append(
$( '<pre></pre>' ).text(
JSON.stringify( err, null, '\t' )
).css( 'background', '#F66' )
)
)
.prependTo( '#mw-content-text' );
} );
/**
* User-defined for [[w:en:User:js/urldecoder]], transforms URL into {{fullurl:...}} on 2nd click
* @return string A valid target for an [external link] (if it matches /^(https?:\/\/|\{\{)/) or of an [[internal link]]
*/
window.urlDecoderCustom = function ( url ) {
var path = mw.config.get( 'wgServer' ) + mw.config.get( 'wgScript' ) + '?title=',
pos = url.indexOf( path ),
result = null;
if ( pos !== -1 ) {
result = url.substring( pos + path.length ).match( /^([^&]+)&?(.*)$/ );
} else {
path = mw.config.get( 'wgServer' ) + '/wiki/';
pos = url.indexOf( path );
if ( pos !== -1 ) {
result = url.substring( pos + path.length ).match( /^([^\?]+)\??(.*)$/ );
} else {
return url;
}
}
if ( mw.config.get( 'wgPageName' ) === result[1] ) {
result[1] = '{{FULLPAGENAME}}';
}
// Note: {{fullurl:A#B|oldid=198639}} is equivalent to {{fullurl:A|oldid=198639#B}}
return '{'+'{fullurl:' + result[1].replace( /%20|_/g, ' ' ) +
( result[2] ? '|' + result[2] : '' ) + '}}';
};
/* Quality checker customizations */
// mw.config.set( 'qcAutoCheck', true );
/* Ajax Preview customizations */
/*window.ajaxPreviewExec = function() {
// Code to execute after each preview update
mw.loader.using( [
'jquery.tablesorter',
'jquery.makeCollapsible'
], function(){
$( 'table.sortable' ).tablesorter();
$( '.mw-collapsible' ).makeCollapsible();
} );
};*/
//<noinclude>
/*
//</noinclude>
if ( isEditOrSubmit ) {
wget( 'https://tools-static.wmflabs.org/meta/scripts/i18n/pt.js' );
}
{{<includeonly>subst:</includeonly>User:He7d3r/Tools/TemplateScript.js}}
{{<includeonly>subst:</includeonly>User:He7d3r/Tools/BookTools.js}}
{{<includeonly>subst:</includeonly>User:He7d3r/Tools/ExtraEditButtons.js}}
{{<includeonly>subst:</includeonly>User:He7d3r/Tools/CodingToolbar.js}}
{{<includeonly>subst:</includeonly>User:He7d3r/Tools/DebugModeToggle.js}}
{{<includeonly>subst:</includeonly>User:He7d3r/Tools/ShortDiff.js}}
{{<includeonly>subst:</includeonly>User:He7d3r/Tools/ExtraLinks.js}}
{{<includeonly>subst:</includeonly>User:He7d3r/Tools/AddActionLinks.js}}
{{<includeonly>subst:</includeonly>User:He7d3r/Tools/LanguageLinksOnCategoryMembers.js}}
{{<includeonly>subst:</includeonly>User:He7d3r/Tools/PermalinkWhenExpandingTemplates.js}}
{{<includeonly>subst:</includeonly>User:He7d3r/Tools/QUnit.js}}
{{<includeonly>subst:</includeonly>User:He7d3r/Tools/WikiBlameLink.js}}
{{<includeonly>subst:</includeonly>User:He7d3r/Tools/CheckImagesWithoutAttribution.js}}
{{<includeonly>subst:</includeonly>User:He7d3r/Tools/PrevRevisionAction.js}}
{{<includeonly>subst:</includeonly>User:He7d3r/Tools/LinksOnJSPages.js}}
{{<includeonly>subst:</includeonly>User:He7d3r/Tools/InterProjectLinks.js}}
{{<includeonly>subst:</includeonly>User:He7d3r/Tools/ClearSandbox.js}}
{{<includeonly>subst:</includeonly>User:He7d3r/Tools/UnwatchFromWatchlist.js}}
if( mw.config.get( 'wgCanonicalSpecialPageName' ) === 'Watchlist' && /\/cw$/.test( mw.config.get( 'wgTitle' ) ) ){
{{<includeonly>subst:</includeonly>User:He7d3r/Tools/CrossWikiWatchlist.js}}
}
{{<includeonly>subst:</includeonly>User:He7d3r/Tools/WarningOnUnsignedComments.js}}
{{<includeonly>subst:</includeonly>User:He7d3r/Tools/EditSandbox.js}}
{{<includeonly>subst:</includeonly>User:He7d3r/Tools/ConvertToSearchLinks.js}}
{{<includeonly>subst:</includeonly>User:He7d3r/Tools/FormatSaleBotRegexes.js}}
{{<includeonly>subst:</includeonly>User:He7d3r/Tools/UserPages.js}}
{{<includeonly>subst:</includeonly>User:He7d3r/Tools/BytesPerEditor.js}}
{{<includeonly>subst:</includeonly>User:He7d3r/Tools/AjaxRollbackLinks.js}}
{{<includeonly>subst:</includeonly>User:He7d3r/Tools/AssessmentHelper.js}}
{{<includeonly>subst:</includeonly>User:He7d3r/Tools/LanguageConverterDistances.js}}
{{<includeonly>subst:</includeonly>User:He7d3r/Tools/SearchOnBadwordsList.js}}
{{<includeonly>subst:</includeonly>User:He7d3r/Tools/ConvertPrefixIndexToList.js}}
{{<includeonly>subst:</includeonly>User:He7d3r/Tools/CollapsibleChangesListOptions.js}}
{{<includeonly>subst:</includeonly>User:He7d3r/Tools/AddLinksToValidationTools.js}}
if( mw.config.get( 'wgTitle' ) !== mw.config.get( 'wgUserName' ) ){
{{<includeonly>subst:</includeonly>User:He7d3r/Tools/TalkPageTools.js}}
}
{{<includeonly>subst:</includeonly>User:He7d3r/Tools/CustomInterface.js}}
{{<includeonly>subst:</includeonly>User:He7d3r/Tools/externISBN.js}}
{{<includeonly>subst:</includeonly>User:He7d3r/Tools/AddMediaWikiVersionLinkToRecentChanges.js}}
window.buttonsForRefsIds = [
'Q18507658', 'Q18384872', 'Q18385108', 'Q18385111', 'Q15633767', 'Q18507726', 'Q18507804',
'Q18507818', 'Q18517565', 'Q18517603', 'Q18517614', 'Q18517606', 'Q18517618', 'Q18517621'
];
{{<includeonly>subst:</includeonly>User:He7d3r/Tools/ButtonsForRefs.js}}
{{<includeonly>subst:</includeonly>User:He7d3r/Tools/DirectImageLinksToCommons.js}}
{{<includeonly>subst:</includeonly>User:He7d3r/Tools/SidebarSlider.js}}
{{<includeonly>subst:</includeonly>User:He7d3r/Tools/jsUpdater.js}}
{{<includeonly>subst:</includeonly>User:He7d3r/Tools/SyncMyTools.js}}
{{<includeonly>subst:</includeonly>User:He7d3r/Tools/CompareTranslations.js}}
{{<includeonly>subst:</includeonly>User:He7d3r/Tools/ChangeRedTalkPageLinks.js}}
{{<includeonly>subst:</includeonly>User:He7d3r/Tools/HighlightSmallDiffs.js}}
{{<includeonly>subst:</includeonly>User:He7d3r/Tools/RevertedChanges.js}}
{{<includeonly>subst:</includeonly>User:He7d3r/Tools/TipsForSlangs.js}}
{{<includeonly>subst:</includeonly>User:He7d3r/Tools/CountHiddenStructuresOnCurrentPage.js}}
{{<includeonly>subst:</includeonly>User:He7d3r/Tools/createDiffLinks.js}}
{{<includeonly>subst:</includeonly>User:He7d3r/Tools/AbuseFilterRegressionTest.js}}
{{<includeonly>subst:</includeonly>User:He7d3r/Tools/AbuseLogStatus.js}}
{{<includeonly>subst:</includeonly>User:He7d3r/Tools/AbuseFilterStats.js}}
{{<includeonly>subst:</includeonly>User:He7d3r/Tools/AbuseFilterExecutionStats.js}}
{{<includeonly>subst:</includeonly>User:He7d3r/Tools/AddLinksToGadgetDescriptionsInContentLanguage.js}}
{{<includeonly>subst:</includeonly>User:He7d3r/Tools/InternalLinkSuggestions.js}}
window.filterInterlanguageLinks = {
msgs: {
'fil-show': 'Mostrar mais $1',
'fil-desc': 'Mostrar/ocultar link(s) que não aparece(m) por padrão',
'fil-hide': 'Ocultar $1'
},
show: [ 'de', 'en', 'es', 'fr', 'gl', 'it', 'pt', 'ru', 'zh' ]
};
{{<includeonly>subst:</includeonly>User:He7d3r/Tools/FilterInterlanguageLinks.js}}
{{<includeonly>subst:</includeonly>User:He7d3r/Tools/ImproveGadgetsDefinition.js}}
{{<includeonly>subst:</includeonly>User:He7d3r/Tools/GlobalPreferences.js}}
{{<includeonly>subst:</includeonly>User:He7d3r/Tools/MarkUnpatrolledContribs.js}}
{{<includeonly>subst:</includeonly>User:He7d3r/Tools/UndoFromDiff.js}}
// mw.config.set( 'ScoredRevisionsThresholds', { low: 0.85, medium: 0.9, high: 0.95 } );
{{<includeonly>subst:</includeonly>User:He7d3r/Tools/ScoredRevisions.js}}
{{<includeonly>subst:</includeonly>User:He7d3r/Tools/ScoredCategories.js}}
{{<includeonly>subst:</includeonly>User:He7d3r/Tools/HighlightTinyText.js}}
$( function () {
$( '#ca-tiny-text' ).click()
} );
// <noinclude>
*/
//</noinclude>
( function ( mw, $ ) {
wget( '[[w:en:User:Js/ajaxPreview.js]]' );
wget( '[[w:en:User:Js/urldecoder.js]]' );
if(
mw.util.getParamValue('diff') !== null ||
mw.config.get( 'wgCanonicalSpecialPageName' ) === 'ComparePages' ||
mw.util.getParamValue( 'action' ) === 'submit'
){
// wget( '[[w:en:User:Cacycle/wikEdDiff.js]]' );
wget( '[[w:de:User:Schnark/js/diff.js]]' );
}
if ( mw.config.get( 'wgCanonicalSpecialPageName' ) === 'Watchlist' && ! /\/cw$/.test( mw.config.get( 'wgTitle' ) ) ) {
wget( '[[w:en:User:Theopolisme/Scripts/ajaxWatchlist.js]]' );
}
wget( '[[w:fr:MediaWiki:Gadget-AncreTitres.js]]' );
wget( '[[mw:MediaWiki:Gadget-UTCLiveClock.js]]' );
wget( '[[c:MediaWiki:Gadget-rightsfilter.js]]' );
// wget( '[[m:User:Remember the dot/Syntax highlighter.js]]' );
/**
* Forces left-to-right layout and editing on RTL wikis.
* @see https://meta.wikimedia.org/wiki/Force_ltr
* @update-token [[File:pathoschild/forceltr.js]]
*/
wget( 'https://tools-static.wmflabs.org/meta/scripts/pathoschild.forceltr.js' );
localStorage['mw-mobile-sidebar-state'] = 'hidden';
wget( '[[m:User:Brion VIBBER/mobile-sidebar.css]]' );
wget( '[[m:User:Brion VIBBER/mobile-sidebar.js]]' );
// wget( '[[m:User:Hedonil/XTools/XTools.js]]' );
if( mw.config.get( 'wgDBname' ) === 'enwiki' ){
wget( '[[w:en:User:Lupin/recent2.js]]' );
}
if( mw.config.get( 'wgDBname' ) === 'wikidatawiki' ){
wget( '[[m:User:He7d3r/Tools/LowerCaseLabels.js]]' );
wget( '[[m:User:He7d3r/Tools/WikidataAutofill.js]]' );
wget( '[[d:User:Joern/altLabels.js]]' );
// wget( '[[d:User:Magnus Manske/wikidata useful.js]]' );
}
if( ___location.host.indexOf( 'wikipedia.org' ) !== -1 ){
wget( '[[d:User:Yair rand/WikidataInfo.js]]' );
wget( '[[d:User:Yair rand/checksitelinks.js]]' );
window.articleTranslatorConf = {
'homeWiki': 'pt'
};
// wget( '[[w:en:User:Ebraminio/ArticleTranslator.js]]' );
// [[w:es:User:Qwertyytrewqqwerty/DisamAssist]]
wget( '[[w:pt:User:Lijealso/DisamAssist.css]]' );
wget( '[[w:pt:User:Lijealso/DisamAssist.js]]' );
if ( /[?&]RLRL(?:S|R|RD)=/.test( document.___location.href ) ){
wget( '[[w:en:User:Topbanana/RLRL SR Utility.js]]' );
}
}
if ( mw.config.get( 'wgCanonicalSpecialPageName' ) === 'Search' ) {
wget( '[[w:en:MediaWiki:Wdsearch.js]]' );
}
if ( mw.config.get( 'wgTitle' ) === 'Krinkle/RTRC'
&& $.inArray( mw.config.get( 'wgAction' ), [ 'view', 'edit' ] ) !== -1
) {
// [[File:Krinkle RTRCdev.js]] (workaround for [[phab:T35355]])
wget( '[[mw:MediaWiki:Gadget-rtrc.css]]' );
wget( '[[mw:MediaWiki:Gadget-rtrc.js]]' );
}
$( function () {
if ( $( '#wikilabels-home' ).length ) {
// TODO: Migrate from this Temporary hack
// Wiki-Labels [[File:User:EpochFail/WikiLabels.js]]
wget( 'https://labels.wmflabs.org/gadget/loader.js' );
}
} );
}( mediaWiki, jQuery ) );
// <noinclude>
// { {<includeonly>subst:</includeonly>User:He7d3r/Tools/InterProjectIcons.js}}
// { {<includeonly>subst:</includeonly>User:He7d3r/Tools/Archiving.js}}
// { {<includeonly>subst:</includeonly>User:He7d3r/Tools/TopContrib.js}}
// { {<includeonly>subst:</includeonly>User:He7d3r/Tools/FixTypos.js}}
// { {<includeonly>subst:</includeonly>User:He7d3r/Tools/myTools.js}}
// { {<includeonly>subst:</includeonly>User:He7d3r/Tools/BlackListChecker.js}}
// [[File:User:He7d3r/Tools/LanguageConverter.js]] (workaround for [[phab:T35355]])
// FIXME: Add JS to import [[User:He7d3r/Tools/LanguageConverterForEnglish.css]]
// { {<includeonly>subst:</includeonly>User:He7d3r/Tools/LanguageConverterForEnglish.js}}
// wget( '[[b:pt:MediaWiki:Gadget-Localizar e substituir.js]]' );
// wget( '[[w:en:MediaWiki:Gadget-LongEditSummaries.js]]' );
// wget( '[[w:en:User:WikiBhasha.MSR/WikiBhasha.js]]' );
// wget( '[[w:en:User:Cacycle/wikEdDiff.js]]' );
// wget( '[[w:de:MediaWiki:Gadget-revisionjumper.js]]' );
// wget( '[[c:MediaWiki:Gadget-HideFundraisingNotice.js]]' );
// wget( '[[c:MediaWiki:Gadget-contribsrange.js]]' );
//</noinclude>
/**
* Do not follow redirects on prefix index lists
*/
if ( 'Prefixindex' === mw.config.get( 'wgCanonicalSpecialPageName' ) ) {
$(function () {
$('.allpagesredirect a').each(function(){
$(this).attr('href', $(this).attr('href') + '?redirect=no');
});
});
}
if ( isEditOrSubmit ) {
$(function () {
var div, x, p, labels;
// transforma as fórmulas LaTeX em toda a página em "botões clicáveis"
div = document.getElementById( 'bodyContent' );
/*jshint camelcase:false */
if( window.wet_LaTeX !== undefined ) {
window.wet_LaTeX(div);
}
/*jshint camelcase:true */
x = document.getElementById( 'wpMinoredit' );
if( !x ) {
return null;
}
p = x.parentNode;
if( !p ) {
return null;
}
labels = p.getElementsByTagName( 'label' );
if ( !labels[1] ) {
return null;
}
if ( 'Marcar como edição menor' === labels[1].innerHTML ){
labels[1].innerHTML = 'Menor';
if ( labels[2] ) {
labels[2].innerHTML = 'Vigiar';
}
}else{
labels[1].innerHTML = 'Vigiar';
if ( labels[0] ) {
labels[0].innerHTML = 'Menor';
}
}
});
}
/* End user scripts */
} else {
$( '#ca-toggle-js' ).find( 'a' ).css( 'color', 'red' );
mw.log.warn( 'Note: Your scripts are disabled.' );
}
/* Loader for scripts from localhost */
/*
enableLocalScripts = $.cookie( 'enable-local-scripts' ) !== 'false';
$( function () {
var label = {
'true': 'Disable local scripts',
'false': 'Enable local scripts'
};
$( mw.util.addPortletLink(
'p-tb',
'#',
label[ enableLocalScripts ],
'ca-local-scripts',
'Turn local scripts on or off and reload the page'
) ).click( function (e) {
// prevent '#' from appearing in URL bar
e.preventDefault();
if ( enableLocalScripts ) {
$.cookie( 'enable-local-scripts', 'false', {
expires: 1,
path: '/'
} );
} else {
$.removeCookie( 'enable-local-scripts', {
expires: 1,
path: '/'
} );
}
// Reloads the document (from the cache)
document.___location.reload( false );
} );
} );
if ( enableLocalScripts ) {
wget(
'http://localhost/w/index.php?title=' +
'User:' + mw.util.wikiUrlencode( mw.config.get( 'wgUserName' ) ) +
'/common.js&action=raw&ctype=text/javascript'
);
}*/
} ); // using mediawiki.util, jquery.cookie
}( mediaWiki, jQuery ) );