User:WOSlinker/common.js
注意:保存之后,你必须清除浏览器缓存才能看到做出的更改。Google Chrome、Firefox、Microsoft Edge及Safari:按住⇧ Shift键并单击工具栏的“刷新”按钮。参阅Help:绕过浏览器缓存以获取更多帮助。
function font_queryString(p) {
var re = RegExp('[&?]' + p + '=([^&]*)');
var matches;
if (matches = re.exec(document.location)) {
try {
return decodeURI(matches[1]);
} catch (e) { }
}
return null;
}
//Add a 'font edit' tab
if(mw.config.get('wgArticleId') != 0 ) {
$( function fontEditButton() {
mw.util.addPortletLink('p-cactions',
mw.util.getUrl(null,{action:'edit',font:true}),
'font',
'p-font',
'font edit7');
}
)}
if(mw.config.get('wgAction') == 'edit' && font_queryString('font') == 'true') {
$(function font() {
var myContent = document.getElementById('wpTextbox1').value;
myContent = myContent.replace(/\<font color *\= *\"\#([\d\w]*)\"\>\[\[([^\]]*?)\|([^\]]*?)\]\]\<\/font\>/g,'[[$2|<font color="#$1">$3</font>]]');
myContent = myContent.replace(/\<font color *\= *\"\#([\d\w]*)\"\>\[\[([^\]]*?)\]\]\<\/font\>/g,'[[$2|<font color="#$1">$2</font>]]');
myContent = myContent.replace(/\<font color *\= *\#([\d\w]*)\>\[\[([^\]]*?)\|([^\]]*?)\]\]\<\/font\>/g,'[[$2|<font color="#$1">$3</font>]]');
myContent = myContent.replace(/\<font color *\= *\#([\d\w]*)\>\[\[([^\]]*?)\]\]\<\/font\>/g,'[[$2|<font color="#$1">$2</font>]]');
myContent = myContent.replace(/\<font color *\= *\"([\w]*)\"\>\[\[([^\]]*?)\|([^\]]*?)\]\]\<\/font\>/g,'[[$2|<font color="$1">$3</font>]]');
myContent = myContent.replace(/\<font color *\= *\"([\w]*)\"\>\[\[([^\]]*?)\]\]\<\/font\>/g,'[[$2|<font color="$1">$2</font>]]');
myContent = myContent.replace(/\<font color *\= *([\w]*)\>\[\[([^\]]*?)\|([^\]]*?)\]\]\<\/font\>/g,'[[$2|<font color=$1>$3</font>]]');
myContent = myContent.replace(/\<font color *\= *([\w]*)\>\[\[([^\]]*?)\]\]\<\/font\>/g,'[[$2|<font color=$1>$2</font>]]');
myContent = myContent.replace(/\<font size *\= *([\d]*) color *\= *\"([\w]*)\"\>\[\[([^\]]*?)\|([^\]]*?)\]\]\<\/font\>/g,'[[$3|<font size=$1 color="$2">$4</font>]]');
myContent = myContent.replace(/\<font size *\= *([\d]*) color *\= *\"([\w]*)\"\>\[\[([^\]]*?)\]\]\<\/font\>/g,'[[$3|<font size=$1 color="$2">$3</font>]]');
myContent = myContent.replace(/\<font size *\= *([\d]*) color *\= *([\w]*)\>\[\[([^\]]*?)\|([^\]]*?)\]\]\<\/font\>/g,'[[$3|<font size=$1 color=$2>$4</font>]]');
myContent = myContent.replace(/\<font size *\= *([\d]*) color *\= *([\w]*)\>\[\[([^\]]*?)\]\]\<\/font\>/g,'[[$3|<font size=$1 color=$2>$3</font>]]');
myContent = myContent.replace(/\<font size *\= *([\d]*\.[\d]*em\;) *color *\= *\"([\w]*)\"\>\[\[([^\]]*?)\|([^\]]*?)\]\]\<\/font\>/g,'[[$3|<font size=$1 color="$2">$4</font>]]');
myContent = myContent.replace(/\<font size *\= *([\d]*\.[\d]*em\;) *color *\= *\"([\w]*)\"\>\[\[([^\]]*?)\]\]\<\/font\>/g,'[[$3|<font size=$1 color="$2">$3</font>]]');
myContent = myContent.replace(/\<font size *\= *([\d]*\.[\d]*em\;) *color *\= *([\w]*)\>\[\[([^\]]*?)\|([^\]]*?)\]\]\<\/font\>/g,'[[$3|<font size=$1 color=$2>$4</font>]]');
myContent = myContent.replace(/\<font size *\= *([\d]*\.[\d]*em\;) *color *\= *([\w]*)\>\[\[([^\]]*?)\]\]\<\/font\>/g,'[[$3|<font size=$1 color=$2>$3</font>]]');
myContent = myContent.replace(/\<font size *\= *([\d]*\.[\d]*em\;) *color *\= *\"([\w]*)\"\>\<noinclude\>\[\[([^\]]*?)\|([^\]]*?)\]\]\<\/noinclude\>\<\/font\>/g,'<noinclude>[[$3|<font color="$2">$4</font>]]</noinclude>');
myContent = myContent.replace(/\<font size *\= *([\d]*\.[\d]*em\;) *color *\= *\"([\w]*)\"\>\<noinclude\>\[\[([^\]]*?)\]\]\<\/noinclude\>\<\/font\>/g,'<noinclude>[[$3|<font color="$2">$3</font>]]</noinclude>');
myContent = myContent.replace(/\<font size *\= *([\d]*\.[\d]*em\;) *color *\= *([\w]*)\>\<noinclude\>\[\[([^\]]*?)\|([^\]]*?)\]\]\<\/noinclude\>\<\/font\>/g,'<noinclude>[[$3|<font color=$2>$4</font>]]</noinclude>');
myContent = myContent.replace(/\<font size *\= *([\d]*\.[\d]*em\;) *color *\= *([\w]*)\>\<noinclude\>\[\[([^\]]*?)\]\]\<\/noinclude\>\<\/font\>/g,'<noinclude>[[$3|<font color=$2>$3</font>]]</noinclude>');
myContent = myContent.replace(/\<font size *\= *([\d]*) color *\= *\"([\w]*)\"\>\<noinclude\>\[\[([^\]]*?)\|([^\]]*?)\]\]\<\/noinclude\>\<\/font\>/g,'<noinclude>[[$3|<font color="$2">$4</font>]]</noinclude>');
myContent = myContent.replace(/\<font size *\= *([\d]*) color *\= *\"([\w]*)\"\>\<noinclude\>\[\[([^\]]*?)\]\]\<\/noinclude\>\<\/font\>/g,'<noinclude>[[$3|<font color="$2">$3</font>]]</noinclude>');
myContent = myContent.replace(/\<font size *\= *([\d]*) color *\= *([\w]*)\>\<noinclude\>\[\[([^\]]*?)\|([^\]]*?)\]\]\<\/noinclude\>\<\/font\>/g,'<noinclude>[[$3|<font color=$2>$4</font>]]</noinclude>');
myContent = myContent.replace(/\<font size *\= *([\d]*) color *\= *([\w]*)\>\<noinclude\>\[\[([^\]]*?)\]\]\<\/noinclude\>\<\/font\>/g,'<noinclude>[[$3|<font color=$2>$3</font>]]</noinclude>');
myContent = myContent.replace(/\<font color *\= *\"\#([\d\w]*)\"\>\[\[([^\]]*?)\|([^\]]*?)\]\]\<\/font color\>/g,'[[$2|<font color="#$1">$3</font>]]');
myContent = myContent.replace(/\<font color *\= *\"\#([\d\w]*)\"\>\[\[([^\]]*?)\]\]\<\/font color\>/g,'[[$2|<font color="#$1">$2</font>]]');
myContent = myContent.replace(/\<font color *\= *\#([\d\w]*)\>\[\[([^\]]*?)\|([^\]]*?)\]\]\<\/font color\>/g,'[[$2|<font color="#$1">$3</font>]]');
myContent = myContent.replace(/\<font color *\= *\#([\d\w]*)\>\[\[([^\]]*?)\]\]\<\/font color\>/g,'[[$2|<font color="#$1">$2</font>]]');
myContent = myContent.replace(/\<font color *\= *\"([\w]*)\"\>\[\[([^\]]*?)\|([^\]]*?)\]\]\<\/font color\>/g,'[[$2|<font color="$1">$3</font>]]');
myContent = myContent.replace(/\<font color *\= *\"([\w]*)\"\>\[\[([^\]]*?)\]\]\<\/font color\>/g,'[[$2|<font color="$1">$2</font>]]');
myContent = myContent.replace(/\<font color *\= *([\w]*)\>\[\[([^\]]*?)\|([^\]]*?)\]\]\<\/font color\>/g,'[[$2|<font color=$1>$3</font>]]');
myContent = myContent.replace(/\<font color *\= *([\w]*)\>\[\[([^\]]*?)\]\]\<\/font color\>/g,'[[$2|<font color=$1>$2</font>]]');
myContent = myContent.replace(/\<font size *\= *([\d]*) color *\= *\"([\w]*)\"\>\[\[([^\]]*?)\|([^\]]*?)\]\]\<\/font color\>/g,'[[$3|<font size=$1 color="$2">$4</font>]]');
myContent = myContent.replace(/\<font size *\= *([\d]*) color *\= *\"([\w]*)\"\>\[\[([^\]]*?)\]\]\<\/font color\>/g,'[[$3|<font size=$1 color="$2">$3</font>]]');
myContent = myContent.replace(/\<font size *\= *([\d]*) color *\= *([\w]*)\>\[\[([^\]]*?)\|([^\]]*?)\]\]\<\/font color\>/g,'[[$3|<font size=$1 color=$2>$4</font>]]');
myContent = myContent.replace(/\<font size *\= *([\d]*) color *\= *([\w]*)\>\[\[([^\]]*?)\]\]\<\/font color\>/g,'[[$3|<font size=$1 color=$2>$3</font>]]');
myContent = myContent.replace(/\<font size *\= *([\d]*\.[\d]*em\;) *color *\= *\"([\w]*)\"\>\[\[([^\]]*?)\|([^\]]*?)\]\]\<\/font color\>/g,'[[$3|<font size=$1 color="$2">$4</font>]]');
myContent = myContent.replace(/\<font size *\= *([\d]*\.[\d]*em\;) *color *\= *\"([\w]*)\"\>\[\[([^\]]*?)\]\]\<\/font color\>/g,'[[$3|<font size=$1 color="$2">$3</font>]]');
myContent = myContent.replace(/\<font size *\= *([\d]*\.[\d]*em\;) *color *\= *([\w]*)\>\[\[([^\]]*?)\|([^\]]*?)\]\]\<\/font color\>/g,'[[$3|<font size=$1 color=$2>$4</font>]]');
myContent = myContent.replace(/\<font size *\= *([\d]*\.[\d]*em\;) *color *\= *([\w]*)\>\[\[([^\]]*?)\]\]\<\/font color\>/g,'[[$3|<font size=$1 color=$2>$3</font>]]');
myContent = myContent.replace(/\<font size *\= *([\d]*\.[\d]*em\;) *color *\= *\"([\w]*)\"\>\<noinclude\>\[\[([^\]]*?)\|([^\]]*?)\]\]\<\/noinclude\>\<\/font color\>/g,'<noinclude>[[$3|<font color="$2">$4</font>]]</noinclude>');
myContent = myContent.replace(/\<font size *\= *([\d]*\.[\d]*em\;) *color *\= *\"([\w]*)\"\>\<noinclude\>\[\[([^\]]*?)\]\]\<\/noinclude\>\<\/font color\>/g,'<noinclude>[[$3|<font color="$2">$3</font>]]</noinclude>');
myContent = myContent.replace(/\<font size *\= *([\d]*\.[\d]*em\;) *color *\= *([\w]*)\>\<noinclude\>\[\[([^\]]*?)\|([^\]]*?)\]\]\<\/noinclude\>\<\/font color\>/g,'<noinclude>[[$3|<font color=$2>$4</font>]]</noinclude>');
myContent = myContent.replace(/\<font size *\= *([\d]*\.[\d]*em\;) *color *\= *([\w]*)\>\<noinclude\>\[\[([^\]]*?)\]\]\<\/noinclude\>\<\/font color\>/g,'<noinclude>[[$3|<font color=$2>$3</font>]]</noinclude>');
myContent = myContent.replace(/\<font size *\= *([\d]*) color *\= *\"([\w]*)\"\>\<noinclude\>\[\[([^\]]*?)\|([^\]]*?)\]\]\<\/noinclude\>\<\/font color\>/g,'<noinclude>[[$3|<font color="$2">$4</font>]]</noinclude>');
myContent = myContent.replace(/\<font size *\= *([\d]*) color *\= *\"([\w]*)\"\>\<noinclude\>\[\[([^\]]*?)\]\]\<\/noinclude\>\<\/font color\>/g,'<noinclude>[[$3|<font color="$2">$3</font>]]</noinclude>');
myContent = myContent.replace(/\<font size *\= *([\d]*) color *\= *([\w]*)\>\<noinclude\>\[\[([^\]]*?)\|([^\]]*?)\]\]\<\/noinclude\>\<\/font color\>/g,'<noinclude>[[$3|<font color=$2>$4</font>]]</noinclude>');
myContent = myContent.replace(/\<font size *\= *([\d]*) color *\= *([\w]*)\>\<noinclude\>\[\[([^\]]*?)\]\]\<\/noinclude\>\<\/font color\>/g,'<noinclude>[[$3|<font color=$2>$3</font>]]</noinclude>');
if(document.getElementById('wpTextbox1').value != myContent) {
document.getElementById('wpTextbox1').value=myContent;
document.getElementById('wpSummary').value='font [[Special:LintErrors/tidy-font-bug|lint]]';
document.getElementById('wpMinoredit').checked = true;
}
}
)}