importScript("User:Ohconfucius/test/Sources_subscript3.js"); //link-fixing, dabbing etc
importScript("User:Ohconfucius/script/foreigndates.js");
function Ohc_linkspam() {
var txt=document.editform.wpTextbox1;
txt.value=txt.value.replace(/([^>\*][ ]?)\[https?:\/\/[^\s\[\]]*[ ]([\'\w\d][^\[\]]*)\](?![ ]*[\n\-]+)/gi, '$1$2');
}
function Ohc_remove_urls() {
/** ------------------------------------------------------------------------ **/
/// PROTECTION BY STRING SUBSTITUTION
var linkmap=[];
function ohc_protect_linkspam()
{
// protects everything within reference tags
// the sensitive part is stored and replaced with a unique identifier,
// which is later replaced with the stored part.
var protect_function = function(s, begin, replace, end) {
linkmap.push(replace);
return begin + "⍌"+(linkmap.length-1)+"⍍" + end;
};
regex(/(<ref[^>]*?>)(.*?)(<\/ref>)/gi, protect_function);
regex(/(\*[ ]?\[(?:https?:|ftp:))([^\]]*)(\])/gi, protect_function);
}
function ohc_unprotect_linkspam()
{
//removes protection put in place by function ohc_protect_fmt (all cats, templates etc.)
regex(/⍌([0-9]+)⍍/g, function(x, n) {
var res = linkmap[n];
res = res.replace(/⍌([0-9]+)⍍/g, function(x, n) {
var res = linkmap[n];
res = res.replace(/⍌([0-9]+)⍍/g, function(x, n) {
var res = linkmap[n];
res = res.replace(/⍌([0-9]+)⍍/g, function(x, n) {
return linkmap[n];
});
return res;
});
return res;
});
return res;
});
}
var linkmap=[];
doaction('diff');
}
function Ohc_linkspam_driver() {
var txt=document.editform.wpTextbox1;
ohc_protect_linkspam();
Ohc_linkspam();
ohc_unprotect_linkspam();
setreason('rem [[WP:Linkspam|linkspam]]', 'append');
}
var add = mw.util.addPortletLink;
$( add('p-tb', '#', 'Linkspam', 's-linkspam', 'removes linkspam in running text', '', '') ).click(prevDef).click(Ohc_linkspam_driver);
$( add('p-tb', '#', 'Unlink source name', 's-unlink', 'Unlinks source', '', '') ).click(prevDef).click(Ohc_sourceunlink);
$( add('p-tb', '#', 'Fix SOURCES', 's-citefix', 'Run entire new module', '', '') ).click(prevDef).click(Ohc_ref_format_new);
|