Wikipedysta:MarMi wiki/common.js
Uwaga: aby zobaczyć zmiany po opublikowaniu, może zajść potrzeba wyczyszczenia pamięci podręcznej przeglądarki.
- Firefox / Safari: Przytrzymaj Shift podczas klikania Odśwież bieżącą stronę, lub naciśnij klawisze Ctrl+F5, lub Ctrl+R (⌘-R na komputerze Mac)
- Google Chrome: Naciśnij Ctrl-Shift-R (⌘-Shift-R na komputerze Mac)
- Edge: Przytrzymaj Ctrl, jednocześnie klikając Odśwież, lub naciśnij klawisze Ctrl+F5.
- Opera: Naciśnij klawisze Ctrl+F5.
console.log("common start");
//window.removeTitles=false; //Navigation popups fix
mw.hook('wikidebug.onerror').add(function (error) {
//[[:pl:MediaWiki:Gadget-wikidebug.js]]
//112 linii
mw.notify('wikidebug');
console.log('wikidebug');
/*var Html, output;
Html = mw.html;
output = Html.element( 'span', {style:"color:red"}, error.message/*, new Html.Raw(
Html.element( 'img', { src: '<' } )
) ); $(output)*/
mw.notify(error.message,{type:"error"}); //'info', 'warn', 'error', 'success'
//message, source, lineno, colno, error
} );
const namespace=mw.config.get( 'wgNamespaceNumber' );
//const wgCN=mw.config.get("wgCanonicalNamespace");
const wgAction=mw.config.get( 'wgAction' );
if ( namespace==0 && wgAction == "edit") {
//[[WP:SK]]
//228 linii
mw.hook('userjs.wp_sk.loaded').add(function (wp_sk) {
//console.log("ve.init?");
//if (!ve.init) {
// console.log("ve.init!");
mw.notify('importScript WP:SK');
console.log('importScript WP:SK');
//[[Wikipedysta:MarMi_wiki/wp_sk.js]]
importScript("Wikipedysta:MarMi_wiki/wp_sk.js");
//}
//mw.loader.load('//pl.wiki.x.io/w/index.php?title=Wikipedysta:MarMi_wiki/wp_sk.js&action=raw&ctype=text/javascript');
} );
}
else if ( namespace==0 && wgAction == "view") {
//test układu kolumn
var cols=$('div[style*=column-count]');
if (cols.length>0)
{
mw.notify("columns-count",cols.length);
console.log("columns-count",cols.length);
cols.each(function() {$(this).css('columns','6 auto')});
cols=$('div[style*=column-width]');
mw.notify("columns-width",cols.length);
console.log("columns-width",cols.length);
cols.each(function() {$(this).css('columns','auto 9vw')});
}
mw.hook('ve.activationComplete').add(function () {
mw.notify('editorInterface',mw.config.get( 'ge-suggestededit-session' ).editorInterface);
console.log('editorInterface',mw.config.get( 'ge-suggestededit-session' ).editorInterface);
try {
const surface = ve.init.target.getSurface();
if ( surface.getMode() === 'source' ) {
//[[:d:User:Yair rand/checksitelinks.js]]
//175 lines
mw.notify('checksitelinks');
console.log('checksitelinks');
mw.loader.load( 'ext.gadget.checksitelinks' );
}
} catch (error) {
mw.notify(error);
console.log(error);
}
});
mw.hook('userjs.veNuxAutocorrect.ready').add(function (nac, helpers) {
//[[:pl:User:Nux/veAutocorrect.js]]
//339 linii
mw.notify('userjs.veNuxAutocorrect.ready');
console.log('userjs.veNuxAutocorrect.ready');
const p = helpers.p;
const h2 = helpers.h2;
/*function (text, skipParagraph) {
var head = [
{type: 'heading', attributes: {level: 2}, internal: {whitespace: ["\n\n",,"\n\n",]}},
text,
{type: '/heading'},
];
var p = [
{type: 'paragraph'},
{type: '/paragraph'},
];
return skipParagraph ? head : head.concat(p);
};*/
const tpl = helpers.tpl;
// extra
/*function pz(text) {
//var textArray = (text?(text.length>0?text.split(''):[""]):[""]);
const pz = [
{type: 'paragraph', internal: {whitespace: [,"\n"]}}, //[ 1, 2, 3, 4 ]: 1 - przed tagiem otwierającym, 2 - po, 3 - przed tagiem zamykającym, 4 - po
//(text?(text.length>0?text:""):""),
{type: '/paragraph'}
];
return pz;
}
function addHead(config) {
nac.add({
from: p(config.start),
to: h2(config.to)
});
}*/
//addHead({start:'=zt', to:'Zobacz też'});
/*function newLine(config) {
nac.add({
from: p(config.start),
to: pz(config.to?config.to:'')
});
}*/
//newLine({start:'=nl', to:'Zobacz też'});
const iso = (new Date()).toISOString();
const ym = iso.substr(0,7);
//testy
/*console.log("pz('1')",pz());
console.log("p('2')",p('2'));
nac.add({
from: p('=t'),
to: [
//h2('Linki zewnętrzne', true),
pz(),
p('')
].flat()
});*/
/*const ve.ui.MWLinkAction = function () { //ve.ui.MWLinkAction
ve.ui.MWLinkAction.super.apply( this, arguments );
};
OO.inheritClass( ve.ui.MWLinkAction, ve.ui.MWTransclusionDialogTool );
ve.ui.MWLinkAction.static.name = 'link'; //Link-Interwiki
/*ve.ui.BoldAnnotationTool.static.group = '';
ve.ui.BoldAnnotationTool.static.icon = 'bold';
ve.ui.BoldAnnotationTool.static.title =
OO.ui.deferMsg( 'visualeditor-annotationbutton-bold-tooltip' );
ve.ui.BoldAnnotationTool.static.annotation = { name: 'textStyle/bold' };
ve.ui.BoldAnnotationTool.static.commandName = 'bold';
ve.ui.toolFactory.register( ve.ui.MWLinkAction );*/
// '{f' -> {{fakt}}
nac.add({
from: '{f',
to: tpl({target: {href: 'Szablon:Fakt',wt: 'fakt'},params: {'data': {wt: ym}}})
});
// '{l' -> {{Link-interwiki}}
nac.add({
from: '{l',
to: tpl({target: {href: 'Szablon:Link-interwiki',wt: 'link-interwiki'}})
});
// '{ki' -> {{Kiedy}}
nac.add({
from: '{ki',
to: tpl({target: {href: 'Szablon:Kiedy',wt: 'kiedy'},params: {'data': {wt: ym}}})
});
// '{d' -> {{Doprecyzuj}}
nac.add({
from: '{d',
to: tpl({target: {href: 'Szablon:Doprecyzuj',wt: 'doprecyzuj'},params: {'data': {wt: ym}}})
});
// '{wa' -> {{Wątpliwe}}
nac.add({
from: '{wa',
to: tpl({target: {href: 'Szablon:Wątpliwe',wt: 'wątpliwe'},params: {'data': {wt: ym}}})
});
// '{o' -> {{Odn}}
nac.add({
from: '{o',
to: tpl({target: {href: 'Szablon:Odn',wt: 'odn'}})
});
// '=p' -> =p + {{Przypisy}}
nac.add({
from: p('=p'),
to: [
h2('Przypisy', true),
tpl({
target: {
href: 'Szablon:Przypisy',
wt: 'Przypisy'
},
}, true)/*,
pz(),
pz()*/
].flat()
});
// '{m' -> {{Martwy link}}
nac.add({
from: '{m',
to: tpl({target: {href: 'Szablon:Martwy link',wt: 'martwy link'},params: {'data': {wt: ym}}})
});
// '{kt' -> {{Kto}}
nac.add({
from: '{kt',
to: tpl({target: {href: 'Szablon:Kto',wt: 'kto'},params: {'data': {wt: ym}}})
});
// '=u' -> =u + {{Uwagi}}
nac.add({
from: p('=u'),
to: [
h2('Uwagi', true), //skipParagraph - bez odstępu po sekcji
tpl({
target: {
href: 'Szablon:Uwagi',
wt: 'Uwagi'
}
}, true), //true=blok - kursor po Uwagi, inaczej kursor przed szablonem (i nie da się wstawiać po nim p)
].flat()
});
// '{b' -> {{Brak strony}}
nac.add({
from: '{b',
to: tpl({target: {href: 'Szablon:Brak strony',wt: 'brak strony'},params: {'data': {wt: ym}}})
});
// '{c' -> {{Czy to ważne}}
nac.add({
from: '{c',
to: tpl({target: {href: 'Szablon:Czy to ważne',wt: 'czy to ważne'},params: {'data': {wt: ym}}})
});
// '{n' -> {{Nie w źródle}}
nac.add({
from: '{n',
to: tpl({target: {href: 'Szablon:Nie w źródle',wt: 'nie w źródle'},params: {'data': {wt: ym}}})
});
// '{p' -> {{Przypisy}}
/*nac.add({
from: '{p',
to: tpl({
target: {
href: 'Szablon:Przypisy',
wt: 'Przypisy'
}
//params: {}
})
});
// '=lz' -> =lz + wypunktowanie
nac.add({
from: p('=lz'),
to: [
h2('Linki zewnętrzne', true),
p('*')
].flat()
});
//addHead({start:'=lz', to:'Linki zewnętrzne'});
// '=b' -> =b + wypunktowanie
nac.add({
from: p('=b'),
to: [
h2('Bibliografia', true),
p('*')
].flat()
});
// '=zt' -> =zt + wypunktowanie
nac.add({
from: p('=zt'),
to: [
h2('Zobacz też', true),
p('*')
].flat()
});
//importScript('MediaWiki:Gadget-NAC-extras.js');
// '{we' -> {{Według kogo}}
nac.add({
from: '{we',
to: tpl({target: {href: 'Szablon:Według kogo',wt: 'według kogo'},params: {'data': {wt: ym}}})
});
// '{j' -> {{Jakich}}
nac.add({
from: '{j',
to: tpl({target: {href: 'Szablon:Jakich',wt: 'jakich'},params: {'data': {wt: ym}}})
});*/
});
if (location.search.indexOf('diff=')<0 && location.search.indexOf('veaction=')<0 &&
location.search.indexOf('search='<0) )
{
//[[Wikipedysta:Msz2001/missing-anchors.js]] gadżet
/*console.log('missing-anchors');
importScript("Wikipedysta:Msz2001/missing-anchors.js");*/
//[[en:User:PerfektesChaos/js/lintHint/r.js]]
//1174 linii
console.log('lintHint');
mw.notify('lintHint');
mw.loader.load( "//en.wiki.x.io/w/index.php?title=User:PerfektesChaos/js/lintHint/r.js&action=raw&ctype=text/javascript" );
}
}
else if ([-1,5,6,7,8,14,102,103,120,828,829].includes(namespace))
{
const wgCSPN=mw.config.get("wgCanonicalSpecialPageName");
if (!wgCSPN || ["ExpandTemplates"].includes(wgCSPN)) //!["ExpandTemplates","Blankpage","LintErrors","Watchlist","PendingChanges","Contributions"].includes(wgCSPN)
mw.notify('lintHint');
console.log('lintHint');
//[[en:User:PerfektesChaos/js/lintHint/r.js]]
//1174 linii
//wgCSPN=false - artykuł
if (!wgCSPN || ["ExpandTemplates"].includes(wgCSPN)) //!["LintErrors","Watchlist","PendingChanges","Contributions"].includes(wgCSPN)
mw.loader.load( "//en.wiki.x.io/w/index.php?title=User:PerfektesChaos/js/lintHint/r.js&action=raw&ctype=text/javascript" );
}
/*mw.hook('ve.activationComplete').add(function () {
console.log('ve.activationComplete');
if (mw.config.get( 'wgLinterErrorLocation' ))
{
console.log('ext.linter.edit');
//mw.loader.state({"ext.linter.edit":"loaded"});
//mw.loader.load( 'ext.linter.edit' );
}
//importScript(':d:User:Yair_rand/checksitelinks.js');
//importScript('User:Nux/veAutocorrect.js');
});*/
/*mw.hook('ext.CodeMirror.switch').add(function (shown, editor) {
if (!shown) return;
if (typeof wersja=="undefined")
{
//[[Wikipedysta:MarMi_wiki/cmTest.js]]
mw.loader.load( "//pl.wiki.x.io/w/index.php?title=Wikipedysta:MarMi_wiki/cmTest.js&action=raw&ctype=text/javascript");
}
mw.hook('userjs.cmTest.testContrast').add(function () {
console.log("inside userjs.cmTest.testContrast");
//3024-d/n=/ abbot= abcdef= ambiance= ayu-d/m=/
//base16-d/l=/ bespin= blackboard= cobalt= colorforth=
//darcula= dracula= duotone-d/l=/ eclipse= elegant=
//erlang-d= gruvbox-d= hopscotch= icecoder= idea=
//isotope= juejin= lesser-d= liquibyte= lucario=
//material-d/o/p/=/// mbo= mdn-l= midnight=
//monokai= moxer= neat= neo= night= nord=
//oceanic-n= panda-s= paraiso-d/l=/ pastel-on-dark=
//railscasts= rubyblue= seti= shadowfox= solarized=
//ssms= the-matrix= tomorrow-night-b/e=1.61/ ttcn= twilight=
//vibrant-i= xq-d/l=/ yeti= yonce= zenburn=
const themes=["default","juejin","bespin","isotope","hopscotch","railscasts","idea","colorforth","cobalt","night","tomorrow-night-bright","rubyblue","panda-syntax","midnight","yeti","lucario","gruvbox-dark","blackboard","the-matrix","abcdef","3024-day","zenburn","seti","dracula","3024-night","paraiso-dark","paraiso-light","nord","mbo","base16-light","vibrant-ink","twilight","monokai","erlang-dark","base16-dark","moxer","ayu-dark","tomorrow-night-eighties","oceanic-next","shadowfox","pastel-on-dark","icecoder","material","ayu-mirage","material-darker","duotone-dark","lesser-dark","darcula","duotone-light","material-ocean","material-palenight","xq-dark","xq-light","yonce","liquibyte"];
/*function getRandomIntInclusive(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min + 1)) + min;
}*/
/*const theme = themes[Math.floor(Math.random()*themes.length)];
console.log("def theme",editor[0].CodeMirror.getOption("theme"));
if (themes.length>0)
{
if (theme!="default")
mw.loader.load(cdn+wersja+'/theme/'+theme+min+'.css','text/css');
editor[0].CodeMirror.setOption("theme",theme);
}
if (themes.length>0)
testContrast();
console.log("theme",theme);
});
mw.hook('userjs.cmTest.styleActiveLine').add(function () {
editor[0].CodeMirror.setOption("styleActiveLine", {nonEmpty:true,noWrap:true});
});
});*/
//dyskusja
//console.log(mw.config.get("wgCanonicalNamespace"));
//if (/talk|project/i.test(mw.config.get("wgCanonicalNamespace")))
//mw.loader.load('https://commons.wikimedia.org/w/index.php?title=User:Jack_who_built_the_house/convenientDiscussions.js&action=raw&ctype=text/javascript');
/*mw.hook('userjs.wp_sk.button_created').add(function () {
console.log('af userjs.wp_sk.button_created');
//[[de:Benutzer:TMg/autoFormatter.js]]
mw.loader.load( '//de.wiki.x.io/w/index.php?title=Benutzer:TMg/autoFormatter.js&action=raw&ctype=text/javascript' );
} );*/
//$.when($.ready).then( function() {
//console.log('c $.when($.ready)');
/*$(".problemy-w-cytuj")
.show("slow")
.css("display", "inline")
.css("color", "red");
//[[en:User:Joeytje50/JWB.js]]
//mw.loader.load('//en.wiki.x.io/w/index.php?title=User:Joeytje50/JWB.js/load.js&action=raw&ctype=text/javascript');
//przestrzeń Artykuły
if (wgCN.length==0)
{
//[[MediaWiki:Gadget-disFixer.js]]
//mw.loader.load( "//pl.wiki.x.io/w/index.php?title=Wikipedysta:MarMi_wiki/disFixer.js&action=raw&ctype=text/javascript");
//mw.loader.load("https://pl.wiki.x.io/w/index.php?action=raw&ctype=text/javascript&smaxage=21600&maxage=86400&title=Wikipedysta:Nux/disFixer.js");
//mw.loader.load("https://pl.wiki.x.io/w/index.php?action=raw&ctype=text/css&smaxage=86400&maxage=259200&title=Wikipedysta:Nux/disFixer.css", "text/css");
//&maxage=86400
//[[en:Wikipedia:AutoEd/complete.js]]
mw.loader.load( '//en.wiki.x.io/w/index.php?title=Wikipedia:AutoEd/complete.js&action=raw&ctype=text/javascript' );
}
else if (wgCN=="Special")
{
//&maxage=86400
//[[en:User:PerfektesChaos/js/lintHint/r.js]]
mw.loader.load( "//en.wiki.x.io/w/index.php?title=User:PerfektesChaos/js/lintHint/r.js&action=raw&ctype=text/javascript" );
}*/
// [[m:User:Jon Harald Søby/diffedit.js]]
/*if ( mw.config.get( 'wgDiffNewId' ) ) {
console.log("diffedit");
mw.loader.load( '//meta.wikimedia.org/w/index.php?title=User:Jon_Harald_Søby/diffedit.js&action=raw&ctype=text/javascript' );
}*/
//});
// initialize the array - only do this once
//window.extraPopupFilters = [];
// define the function
/*function popupFilterPowerOf10 (wikiText) {
if (/10^\d+/.test(wikiText)) {
console.log('10<sup>'+/10^(\d+)/.exec(wikiText)[1]+'<sup>');
return '10<sup>'+/10^(\d+)/.exec(wikiText)[1]+'<sup>';
}
else return '';
}*/
// add the function to the array (you can repeat this for lots of functions)
//extraPopupFilters.push(popupFilterPowerOf10);
// install [[:Wikipedia:User:Cacycle/wikEd]] in-browser text editor
/*(function ()
{
var script = document.createElement('script'); //Wikipedysta:MarMi_wiki/wikiEd.js
script.src = 'https://pl.wiki.x.io/w/index.php?title=Wikipedysta:MarMi_wiki/wikEd.js&action=raw&ctype=text/javascript';
script.async = true;
document.getElementsByTagName('head')[0].appendChild(script);
}
) ();
*/
/* var wikEdConfig = {};
//wikEdConfig.languageDefault = 'pl';
// install the English translation for [[en:User:Cacycle/wikEd]]
mw.loader.load('//en.wiki.x.io/w/index.php?title=User:Konradek/wikEd_international_pl.js'
+ '&action=raw&ctype=text/javascript');
//var wikEdConfig = {};
wikEdConfig.loadTranslation = false;*/
//importScript('Wikipedysta:MarMi_wiki/customizeToolbar.js');
// non-mobile
/*if (location.host.search(/^\w+\.m\./) < 0) {
var oNL = {} //new cNuxLoader();
oNL.ready = function (varName) {
console.log(varName)
//return this;
};
oNL.load = function(strWikiURI, oUserOptions)
{
console.log(strWikiURI)
console.log(oUserOptions)
this.runAfter=function(varName, initFunction){
mw.loader.getScript('https://pl.wiki.x.io/wiki/'+strWikiURI).then(function () {
initFunction.call(window)
}, function ( e ) {
// Script failed. X is not available
mw.log.error( e.message ); // => "Failed to load script"
} );
}
return this;
};
//oNL.load('User:Nux/nuxedtoolkit.js').runAfter('nuxedtoolkit', loadMissing);
//oNL.ready('nuxedtoolkit');
}
*/
//importScript('Wikipedysta:Nux/htag.js')
console.log("common end");