User:Alex6122/global.js

(function($, document, mw) {   'use strict';    function importjs_links {        console.log(mw.config.values.wgPageName);

// let page_name = mw.config.values.wgPageName; // if (page_name != 'MediaWiki:ImportJS') { // return; // }       // console.log(page_name); console.log(mw.config.values.wgPageName != 'MediaWiki:ImportJS'); console.log('TEST6');/*

let pre = $('#mw-content-text pre').first;

if (!$(pre).length || $('pre').data('linked') ) { return; }

let pre_text = $(pre).text;

if (!pre_text.length) { return; }

let lines = pre_text.split('\n');

let links = lines.map( (line) => {           return line.split(':').reverse;        });

let dev_wiki = 'dev'; let out_html = '';

let dev_link_url = 'https://' + dev_wiki + mw.config.values.wgCookieDomain; let cur_link_url = mw.config.values.wgServer; let path = (mw.config.values.wgArticlePath).replace(/\$1/gi, '');

links.forEach( (line, n) => {

let line_html = '';

if (!line[0].length) {

out_html += '\n'; return ; } else if ((line[1] && line[1] != dev_wiki) || !line[1] || line.length > 2) {

out_html += lines[n] + '\n'; return ;

} else if (line[1] == dev_wiki) { new_line = [dev_link_url + /wiki/, line[0], dev_wiki + ':' ];

} else {

new_line = [cur_link_url + path, line[0], ''];

}           out_html += `${new_line[2]}${new_line[1]} \n`;

});

//        if (!$('#test_pre').length) //            $(pre).after.after(' ');

//        $('#test_pre').html(out_html); $(pre).data('linked', 'yes'); $(pre).html(out_html);*/

// return; }

mw.hook('wikipage.content').add(importjs_links); })(window.jQuery, document, window.mediaWiki);