Widget:WIKI投稿页面编辑器
<script
src="//wiki.biligame.com/seerwar/MediaWiki:2.0.0-dev.3/quill.min.js?action=raw&ctype=text/javascript&r=5"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/quill/2.0.0-dev.3/quill.snow.min.css" rel="stylesheet"> <script
src="https://wiki.biligame.com/seerwar/MediaWiki:Quill-better-table.min.js?action=raw&ctype=text/javascript"></script>
<script src="https://wiki.biligame.com/data/index.php?title=MediaWiki:Api.js&action=raw&ctype=text/javascript"></script> <script
src="https://wiki.biligame.com/seerwar/index.php?title=MediaWiki:Tucao.js&action=raw&ctype=text/javascript"></script>
<script id="rendered-js">
Quill.register({
'modules/better-table': quillBetterTable
},
true);
window.onload = () => {
const quill = new Quill('#editor', {
theme: 'snow',
modules: {
table: true,
toolbar: {
container: [
[{ 'size': ['small', false, 'large', 'huge'] }], // custom dropdown
[{ 'header': [1, 2, 3, 4, 5, 6, false] }],
[{ 'color': [] }, { 'background': [] }], // dropdown with defaults from theme
[{ 'align': [] }],
['bold', 'italic', 'underline', 'strike', 'link', 'image', 'video', 'table'], // toggled buttons
['blockquote', 'code-block'],
[{ 'header': 1 }, { 'header': 2 }], // custom button values
[{ 'list': 'ordered' }, { 'list': 'bullet' }],
[{ 'script': 'sub' }, { 'script': 'super' }], // superscript/subscript
[{ 'indent': '-1' }, { 'indent': '+1' }], // outdent/indent
[{ 'direction': 'rtl' }], // text direction
['clean']
],
handlers: {
table: function (val) {
this.quill.getModule('better-table').insertTable(3, 3)
}
}
},
'better-table': {
operationMenu: {
items: {
unmergeCells: {
text: 'Another unmerge cells name'
},
insertColumnRight: { text: '右边插入一列' },
insertColumnLeft: { text: '左边插入一列' },
insertRowUp: { text: '上边插入一行' },
insertRowDown: { text: '下边插入一行' },
mergeCells: { text: '合并单元格' },
unmergeCells: { text: '拆分单元格' },
deleteColumn: { text: '删除列' },
deleteRow: { text: '删除行' },
deleteTable: { text: '删除表格' }
},
color: {
colors: ['green', 'red', 'yellow', 'blue', 'white'],
text: 'Background Colors:'
}
}
}
// keyboard: {
// bindings: quillBetterTable.keyboardBindings
// }
}
});
let tableModule = quill.getModule('better-table');
document.body.querySelector('#insert-table').
onclick = () => {
tableModule.insertTable(3, 3);
};
document.body.querySelector('#get-table').
onclick = () => {
console.log(tableModule.getTable());
};
document.body.querySelector('#get-contents').
onclick = () => {
updateDeltaView(quill);
};
};
function updateDeltaView(quill) {
document.body.querySelector('#delta-view').
innerHTML = JSON.stringify(
quill.getContents());
} //# sourceURL=pen.js
</script> <script>
window.addEventListener('load', function () {
var u = (document.cookie.match(/DedeUserID=([^;]+)/) || [])[1] || "";
var dz = mw.config.values.wgGameName;
var vcname = dz.slice(0, 1).toUpperCase()
var moban
var other
var ver = `1.0.0`;
var sj = parseInt(Math.random(100) * 10).toString() + parseInt(Math.random(100) * 10).toString() + parseInt(Math.random(100) * 10).toString()
var VC = `${vcname}VC${parseInt(Math.round(new Date() / 1000) + sj).toString(32).toUpperCase()}`
window.vc = VC
window.DZ = dz
document.getElementById("inputDOM").innerHTML = `
<tbody></tbody>| 基础信息 | |||
|---|---|---|---|
| <textarea maxlength="" placeholder="请输入标题(建议30字以内)" style="overflow-y: hidden;height: auto;border: 0px;font-size: 28px;padding: 12px 50px 12px 0px;font-weight: 700;line-height: 40px;width: 100%;" id="title"></textarea> | |||
| 发布模式: | <form name="Publishingmode"><input type="radio" name="gender" onclick="getmodenValue()" value="投稿模式" checked> 投稿模式 <input type="radio" name="gender" onclick="getmodenValue()" value="直发模式"> 直发模式 </form> | ||
| 投稿封面: | <input type="file" id="imageLoader" name="imageLoader" onchange="img1cover()" style="display:none;"> | ||
| 投稿分区: | <select id="lx" tabindex="6" name="类别" class="createboxInput pfShowIfSelected" onchange="fenqu()"><option value="">--请选择稿件分区--</option><option value="攻略视频" style="display: none;">攻略视频</option><option value="同人文">同人文</option><option value="专栏攻略">专栏攻略</option><option value="同人视频" style="display: none;">同人视频</option><option value="同人图">同人图</option><option value="表情包">表情包</option><option value="cosplay">cosplay</option></select> | ||
| 类型: | <select id="yuan" tabindex="6" name="同人图片[是否原创]" class="createboxInput pfShowIfSelected" onchange="yc()"><option value="">--请选择类型--</option><option value="自制">自制</option><option value="转载">转载</option></select> | ||
| 时间: | <input id="time" type="date"> | ||
| 作者: | <input id="up" tabindex="4" class="createboxInput mandatoryField" size="35" name="同人图片[作者]"> | ||
| B站昵称: | <input id="bname" tabindex="4" class="createboxInput mandatoryField" size="35" name="同人图片[作者]"> | ||
| B站UID: | <input id="BUID" tabindex="5" class="createboxInput mandatoryField" size="35" name="同人图片[B站UID]" value="${u}"> | ||
| 相关角色: | <input id="xgjs" tabindex="4" class="createboxInput mandatoryField" size="35" name="同人图片[作者]"> | ||
| 合集 | <select id="sfhj" tabindex="6" name="合集[是否原创]" class="createboxInput pfShowIfSelected" onchange="heji()"><option value=""></option><option value="是">是</option><option value="否">否</option></select><select id="collection" tabindex="6" name="合集[是否原创]" class="createboxInput pfShowIfSelected" onchange="heji()"><option value=""></option><option value="合集标题1" scvalue="SCXXXXX1">合集名称1(SCXXXX1)</option><option 合集标题2="">合集名称2(SCXXXX2)</option></select><input id="hj" tabindex="5" class="createboxInput mandatoryField" size="35" name="同人图片[B站UID]" style="display: none;"><button class="setupcolle">创建合集</button> | ||
| 定时发布: | <select id="sfdingshi" tabindex="6" name="定时[是否]" class="createboxInput pfShowIfSelected" onchange="ds()"><option value="">--是否定时--</option><option value="是">是</option><option value="否">否</option></select><input type="datetime-local" id="ding-datetime" style="display: none;"> | ||
` document.getElementById("btnDOM").innerHTML = `
Ver ${ver}
<button class='submit-btn-group-add' id='btn' style='display: inline-block;height: 40px;font-size: 14px;border-radius: 42px;text-align: center;vertical-align: middle; width: 120px; border: #fff0;cursor: pointer;line-height: 40px;color: #fff;background: #37c8f7;'>立即投稿</button><button class="fankui" type="button">
`
//设置元素可见度及样式
getmodenValue();
document.getElementById('zizhi').style.display = "none"
document.getElementsByClassName("zhuanzai")[0].style.display = "none"
document.getElementById('ding-datetime').style.display = "none"
document.querySelector("tr.ugc-heji").style.display = "none"
document.querySelector("tr.timedrelease").style.display = "none"
document.querySelector("tr.mode").style.display = "none"
document.querySelector("tr.biliname").style.display = "none"
document.querySelector("tr.biliuid").style.display = "none"
document.getElementById('hj').style.display = "none"
document.getElementById('btn').disabled = true
document.getElementById('btn').style.background = "#e5e9ef"
document.getElementById('btn').style.color = "#99a2aa"
if (mw.config.values.wgUserGroups.indexOf("sysop") != -1) {
document.querySelector("tr.mode").style.display = ""
document.querySelector("tr.biliname").style.display = ""
document.querySelector("tr.biliuid").style.display = ""
}
//设置元素value值
document.getElementById("BUID").value = u;
$.getJSON(`https://wiki.biligame.com/data/%E7%94%A8%E6%88%B7%E8%AE%A8%E8%AE%BA:GLOBAL/DeepEye/UserCard/${u}.json?action=raw&ctype=text/json`, function (result) {
pwd = `DeepEye`
str = result.body
pwd = new TextEncoder().encode(pwd)
str1 = JSON.parse(new TextDecoder().decode(pako.ungzip(new Uint8Array(atob(str).split("").map((e, i, a) => e.charCodeAt(0) ^ pwd[i % pwd.length])))))
document.getElementById("bname").value = `${str1.name}`;
window.usernames = `${str1.name}`;
window.userfaces = `${str1.face}`;
});
$('.fankui').on('click', function () {
var data = {
"nickname": `${window.usernames}`,
"avatar": `${window.userfaces}`,
"openid": `bili${u}`,
};
var productId = 653945; // 把1221数字换成你的产品ID,否则会不成功
handleOnclick()
function handleOnclick() {
Tucao.request(productId, data);
}
//console.log('button.fankui 被点击了!');
});
//document.getElementById("bname").value = UserStatus.userInfo.uname;
//封面按钮处理事件
$('.xuankuang').on('click', function () {
$('input#imageLoader').trigger('click');
});
//提交主函数
document.getElementById("btn").onclick = function () {
var xycode = [];
var fqq = document.getElementById("lx").value
var lxx = document.getElementById("yuan").value
var titx = document.getElementById("title").value
var zhuan1 = document.getElementById("input_7").value
var zhuan2 = document.getElementById("input_8").value
var quillinnerHTML = document.getElementsByClassName("ql-editor")[0].innerHTML
switch (modenValue) {
case `直发模式`: {
if (titx != "") {
var $qlEditor = $('.ql-editor'); // 获取ql-editor文本框的jQuery对象
var imgIndex = 1; // 初始化编号为0
window.title1 = document.getElementById("title").value.replace(/</g, "<").replace(/>/g, ">")
function upload() {
var canvas = document.getElementById('imageCanvas');
var base64 = canvas.toDataURL('image/png');
var file = base64ConvertFile(base64, `${VC}-0.png`);
new mw.Api().upload(file, { filename: `${VC}-0.png`, ignorewarnings: true })
//alert(`上传成功惹!٩(๑>◡<๑)۶ `);
}
if (document.querySelector("input#imageLoader").value != "") {
upload()
} else { }
quillinnerHTML = replaceIframeWithWidget(quillinnerHTML)
$qlEditor.find('img').each(function () {
var imgSrc = $(this).attr('src'); // 获取当前img的src值
submitAndReplaceImg(imgSrc); // 提交src值并替换img标签
// 注意:这里不需要在.each()的回调内部处理递归,因为submitAndReplaceImg会自行处理
});
function submitAndReplaceImg(imgSrc) {
var filename = `${VC}-${imgIndex}`;
var img = new Image();
img.src = imgSrc;
var file = base64ConvertFile(imgSrc, filename); // 注意这里不再硬编码".png"
var mimeType = file.type;
var fileExt = mimeType.split('/')[1]; // 提取出子类型作为文件扩展名
// 从file对象中获取MIME类型,并提取出文件扩展名
img.onload = function () {
var canvas = document.getElementById('imgsCanvas');
var ctx = canvas.getContext('2d');
var maxWidth = (img.width > 5000) ? img.width / 3 : img.width;
var maxHeight = (img.height > 5000) ? img.height / 3 : img.height;
// 计算缩放比例
var width = img.width;
var height = img.height;
if (width > height) {
if (width > maxWidth) {
height *= maxWidth / width;
width = maxWidth;
}
} else {
if (height > maxHeight) {
width *= maxHeight / height;
height = maxHeight;
}
}
// 设置canvas的尺寸
canvas.width = width;
canvas.height = height;
// 在canvas上绘制图片
ctx.drawImage(img, 0, 0, width, height);
// 将canvas转换为base64
var base64 = canvas.toDataURL(`${mimeType}`); // 或者使用其他MIME类型
// 将base64转换为File对象(假设你有这个函数)
var file = base64ConvertFile(base64, filename + `.${fileExt}`);
new mw.Api().upload(file, { filename: filename + `.${fileExt}`, ignorewarnings: true })
.then(function (response) {
// 上传成功后的处理逻辑
console.log('上传成功:', response);
})
/*var size = file.size;
var sizes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
var i = Math.floor(Math.log(size) / Math.log(1024));
var d = (size / Math.pow(1024, i)).toPrecision(3) + ' ' + sizes[i];*/
//document.getElementById("imgeSize").innerHTML = d;
};
// API调用成功后的处理逻辑
console.log('API调用成功惹!٩(๑>◡<๑)۶ ');
// 替换img标签为带有顺序编号的文本格式
$qlEditor.find('img[src="' + imgSrc + '"]').replaceWith(`[[文件:${VC}-${imgIndex}.${fileExt}]]`);
imgIndex++; // 递增编号
// 检查是否还有剩余的img需要处理
var $remainingImgs = $qlEditor.find('img');
if ($remainingImgs.length > 0) {
// 如果有剩余的img,递归调用submitAndReplaceImg处理下一个img
submitAndReplaceImg($remainingImgs.first().attr('src'));
}
quillinnerHTML = document.getElementsByClassName("ql-editor")[0].innerHTML
}
Submittodatawikismall(VC, window.title1, document.getElementById("yuan").value, document.getElementById("lx").value, modenValue, document.getElementById("up").value.replace(/</g, "<").replace(/>/g, ">"), document.getElementById("bname").value.replace(/</g, "<").replace(/>/g, ">"), document.getElementById("BUID").value.replace(/</g, "<").replace(/>/g, ">"), document.getElementById("xgjs").value.replace(/</g, "<").replace(/>/g, ">"), ``, document.getElementById("shengming").value, document.getElementById("input_7").value, document.getElementById("input_8").value, document.getElementById("time").value.replace(/</g, "<").replace(/>/g, ">"), ``, window.title1, ``, imgIndex)
//处理提交函数↑
var regex = /<colgroup[^>]*>.*?<\/colgroup>/gi;
var regex1 = /<tbody[^>]*>.*?<\/tbody>/gi;
if (regex.test(quillinnerHTML)) {
console.log('字符串中包含 <colgroup> 标签');
quillinnerHTML = removeColgroupsRegex(quillinnerHTML);
}
if (regex1.test(quillinnerHTML)) {
console.log('字符串中包含 <tbody> 标签');
quillinnerHTML = removeColgroupsRegex1(quillinnerHTML);
}
getApi(`https://wiki.biligame.com/${dz}/api.php?action=query&meta=tokens&format=json`, function (json) { let token = JSON.parse(json).query.tokens.csrftoken let url = `https://wiki.biligame.com/${dz}/api.php` let fd = new FormData() fd.append("action", "edit") fd.append("title", `${window.title1}`) fd.append("text", `${quillinnerHTML}`) fd.append("token", token) fd.append("format", "json") postFdApi(url, fd) window.onbeforeunload = function () { } document.querySelector("#BWIKIPopUp").style.display = "";
document.querySelector("#BWIKIPopUp #BWIKIwindow").innerHTML = `
`
})
} else {
document.getElementById("Info").innerHTML = document.getElementById("Info").innerHTML + '
×错误!请填写标题后再试一下吧o(╥﹏╥)o
'
//alert(`投稿失败,请填写标题后再试一下吧o(╥﹏╥)o`);
}
break;
}
case `投稿模式`: {
var submissiontype;
if (fqq == "") {
xycode[xycode.length] = 101;
}
if (lxx == "") {
xycode[xycode.length] = 102;
}
if (titx == "") {
xycode[xycode.length] = 103;
}
if (document.querySelector("input#imageLoader").value == "") {
xycode[xycode.length] = 106;
}
if (document.getElementById("yuan").value == "转载") {
if (zhuan1 == "") {
xycode[xycode.length] = 104;
}
if (zhuan2 == "") {
xycode[xycode.length] = 105;
}
} else { }
//分区对应模板更改
switch (fqq) {
case `攻略视频`:
submissiontype = ``;
break;
case `专栏攻略`:
submissiontype = `{{${window.moban}|标题=${document.querySelector("textarea#title").value}|更新时间=|作者=${document.querySelector("input#bname").value}|SVC=${VC}|UID=${document.querySelector("input#BUID").value}|B站昵称=${document.querySelector("input#bname").value}|是否原创=${lxx}|相关角色=${document.querySelector("input#xgjs").value}|内容=${quillinnerHTML}|来源=${zhuan1}|原文地址=${zhuan2}|是否显示合集=|合集名称=|是否定时=|定时=|自制声明=}}`;
break;
case `同人文`:
submissiontype = `{{${window.moban}|标题=${document.querySelector("textarea#title").value}|更新时间=|作者=${document.querySelector("input#bname").value}|SVC=${VC}|UID=${document.querySelector("input#BUID").value}|B站昵称=${document.querySelector("input#bname").value}|是否原创=${lxx}|相关角色=${document.querySelector("input#xgjs").value}|内容=${quillinnerHTML}|来源=${zhuan1}|原文地址=${zhuan2}|是否显示合集=|合集名称=|是否定时=|定时=|自制声明=}}`;
break;
case `同人图`:
submissiontype = `{{${window.moban}|图片=${quillinnerHTML}|时间=${document.querySelector("input#time").value}|是否显示合集=${document.querySelector("select#sfhj").value}|合集名称=|作者=${document.querySelector("input#bname").value}|B站UID=${document.querySelector("input#BUID").value}|是否原创=${lxx}|来源=${zhuan1}|原文地址=${zhuan2}}}`;
break;
case `同人视频`:
submissiontype = ``;
break;
case `表情包`:
submissiontype = `{{${window.moban}|图片=${quillinnerHTML}|时间=${document.querySelector("input#time").value}|是否显示合集=${document.querySelector("select#sfhj").value}|合集名称=|作者=${document.querySelector("input#bname").value}|B站UID=${document.querySelector("input#BUID").value}|是否原创=${lxx}|来源=${zhuan1}|原文地址=${zhuan2}}}`;
break;
case `cosplay`:
submissiontype = `{{${window.moban}|图片=${quillinnerHTML}|时间=${document.querySelector("input#time").value}|是否显示合集=${document.querySelector("select#sfhj").value}|合集名称=|作者=${document.querySelector("input#bname").value}|B站UID=${document.querySelector("input#BUID").value}|是否原创=${lxx}|来源=${zhuan1}|原文地址=${zhuan2}}}`;
break;
}
xycode[xycode.length] = 0;
if (xycode[0] == 0) {
if (xycode.length == 1) {
function upload() {
var canvas = document.getElementById('imageCanvas');
var base64 = canvas.toDataURL('image/png');
var file = base64ConvertFile(base64, `${VC}-0.png`);
new mw.Api().upload(file, { filename: `${VC}-0.png`, ignorewarnings: true })
//alert(`上传成功惹!٩(๑>◡<๑)۶ `);
}
upload()
quillinnerHTML = replaceIframeWithWidget(quillinnerHTML)
var $qlEditor = $('.ql-editor'); // 获取ql-editor文本框的jQuery对象
var imgIndex = 1; // 初始化编号为0
window.title1 = document.getElementById("title").value.replace(/</g, "<").replace(/>/g, ">")
$qlEditor.find('img').each(function () {
var imgSrc = $(this).attr('src'); // 获取当前img的src值
submitAndReplaceImg(imgSrc); // 提交src值并替换img标签
// 注意:这里不需要在.each()的回调内部处理递归,因为submitAndReplaceImg会自行处理
});
function submitAndReplaceImg(imgSrc) {
var filename = `${VC}-${imgIndex}`;
var img = new Image();
img.src = imgSrc;
var file = base64ConvertFile(imgSrc, filename); // 注意这里不再硬编码".png"
var mimeType = file.type;
var fileExt = mimeType.split('/')[1]; // 提取出子类型作为文件扩展名
// 从file对象中获取MIME类型,并提取出文件扩展名
img.onload = function () {
var canvas = document.getElementById('imgsCanvas');
var ctx = canvas.getContext('2d');
var maxWidth = (img.width > 5000) ? img.width / 3 : img.width;
var maxHeight = (img.height > 5000) ? img.height / 3 : img.height;
// 计算缩放比例
var width = img.width;
var height = img.height;
if (width > height) {
if (width > maxWidth) {
height *= maxWidth / width;
width = maxWidth;
}
} else {
if (height > maxHeight) {
width *= maxHeight / height;
height = maxHeight;
}
}
// 设置canvas的尺寸
canvas.width = width;
canvas.height = height;
// 在canvas上绘制图片
ctx.drawImage(img, 0, 0, width, height);
// 将canvas转换为base64
var base64 = canvas.toDataURL(`${mimeType}`); // 或者使用其他MIME类型
// 将base64转换为File对象(假设你有这个函数)
var file = base64ConvertFile(base64, filename + `.${fileExt}`);
new mw.Api().upload(file, { filename: filename + `.${fileExt}`, ignorewarnings: true })
.then(function (response) {
// 上传成功后的处理逻辑
console.log('上传成功:', response);
})
/*var size = file.size;
var sizes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
var i = Math.floor(Math.log(size) / Math.log(1024));
var d = (size / Math.pow(1024, i)).toPrecision(3) + ' ' + sizes[i];*/
//document.getElementById("imgeSize").innerHTML = d;
};
// API调用成功后的处理逻辑
console.log('API调用成功惹!٩(๑>◡<๑)۶ ');
// 替换img标签为带有顺序编号的文本格式
$qlEditor.find('img[src="' + imgSrc + '"]').replaceWith(`[[文件:${VC}-${imgIndex}.${fileExt}]]`);
imgIndex++; // 递增编号
// 检查是否还有剩余的img需要处理
var $remainingImgs = $qlEditor.find('img');
if ($remainingImgs.length > 0) {
// 如果有剩余的img,递归调用submitAndReplaceImg处理下一个img
submitAndReplaceImg($remainingImgs.first().attr('src'));
}
quillinnerHTML = document.getElementsByClassName("ql-editor")[0].innerHTML
}
Submittodatawikismall(VC, window.title1, document.getElementById("yuan").value, document.getElementById("lx").value, modenValue, document.getElementById("up").value.replace(/</g, "<").replace(/>/g, ">"), document.getElementById("bname").value.replace(/</g, "<").replace(/>/g, ">"), document.getElementById("BUID").value.replace(/</g, "<").replace(/>/g, ">"), document.getElementById("xgjs").value.replace(/</g, "<").replace(/>/g, ">"), ``, document.getElementById("shengming").value, document.getElementById("input_7").value, document.getElementById("input_8").value, document.getElementById("time").value.replace(/</g, "<").replace(/>/g, ">"), ``, VC, ``, imgIndex)
//处理提交函数↑
var regex = /<colgroup[^>]*>.*?<\/colgroup>/gi;
var regex1 = /<tbody[^>]*>.*?<\/tbody>/gi;
if (regex.test(quillinnerHTML)) {
console.log('字符串中包含 <colgroup> 标签');
quillinnerHTML = removeColgroupsRegex(quillinnerHTML);
}
if (regex1.test(quillinnerHTML)) {
console.log('字符串中包含 <tbody> 标签');
quillinnerHTML = removeColgroupsRegex1(quillinnerHTML);
}
getApi(`https://wiki.biligame.com/${dz}/api.php?action=query&meta=tokens&format=json`, function (json) { let token = JSON.parse(json).query.tokens.csrftoken let url = `https://wiki.biligame.com/${dz}/api.php` let fd = new FormData() fd.append("action", "edit") fd.append("title", `${VC}`) fd.append("text", `${quillinnerHTML}`) fd.append("token", token) fd.append("format", "json") postFdApi(url, fd) window.onbeforeunload = function () { } document.querySelector("#BWIKIPopUp").style.display = "";
document.getElementById("toolsall").innerHTML = `
`
})
}
} else {
var i = 0;
let intervalId = setInterval(fetchData, 100);
function fetchData() {
if (xycode[i] != 0) {
document.getElementById("Info").style.display = ""
switch (xycode[i]) {
case 101: {
document.getElementById("Info").innerHTML = document.getElementById("Info").innerHTML + '
×错误!请选择投稿分区后再试一下吧o(╥﹏╥)o
'
i = i + 1;
break;
}
case 102: {
document.getElementById("Info").innerHTML = document.getElementById("Info").innerHTML + '
×错误!请选择类型后再试一下吧o(╥﹏╥)o
'
i = i + 1;
break;
}
case 103: {
document.getElementById("Info").innerHTML = document.getElementById("Info").innerHTML + '
×错误!请填写标题后再试一下吧o(╥﹏╥)o
'
i = i + 1;
break;
}
case 104: {
document.getElementById("Info").innerHTML = document.getElementById("Info").innerHTML + '
×错误!请填写【转载】来源后再试一下吧o(╥﹏╥)o
'
i = i + 1;
break;
}
case 105: {
document.getElementById("Info").innerHTML = document.getElementById("Info").innerHTML + '
×错误!请填写【转载】原文地址后再试一下吧o(╥﹏╥)o
'
i = i + 1;
break;
}
case 106: {
document.getElementById("Info").innerHTML = document.getElementById("Info").innerHTML + '
×错误!请上传投稿封面后再试一下吧o(╥﹏╥)o
'
i = i + 1;
break;
}
case 107: {
break;
}
}
} else {
clearInterval(intervalId);
}
}
}
break;
}
}
}
window.onbeforeunload = function () {
return "您的投稿尚未保存!";
}
});
function goagain() {
document.getElementById("ca-purge").getElementsByTagName("a")[0].click()
}
function gopage() {
switch (modenValue) {
case `直发模式`: {
(window.RLQ = window.RLQ || []).push(['jquery', () => {
location.href = `https://wiki.biligame.com/${DZ}/${window.title1}`;
}]);
break;
}
case `投稿模式`: {
(window.RLQ = window.RLQ || []).push(['jquery', () => {
location.href = `https://wiki.biligame.com/${DZ}/${vc}`;
}]);
break;
}
}
}
function fenqu() {
(window.RLQ = window.RLQ || []).push(['jquery', () => {
$(document).ready(function () {
var lx = document.getElementById("lx").value
switch (lx) {
case "同人图":
window.moban = "同人图片|类别=同人图片";
break;
case "表情包":
window.moban = "同人图片|类别=表情包";
break;
case "cosplay":
window.moban = "同人图片|类别=cosplay";
break;
case "攻略视频":
window.moban = "视频模板|类别=攻略视频";
break;
case "同人视频":
window.moban = "视频模板|类型=同人视频";
break;
case "专栏攻略":
window.moban = "文章模板|类型=专栏攻略";
break;
case "同人文":
window.moban = "文章模板|类型=同人文";
break;
}
})
}]);
}
function yc() {
(window.RLQ = window.RLQ || []).push(['jquery', () => {
$(document).ready(function () {
var yuan = document.getElementById("yuan").value
if (yuan == '自制') {
document.getElementById('zizhi').style.display = "revert"
document.getElementsByClassName("zhuanzai")[0].style.display = "none"
} else {
if (yuan == '转载') {
document.getElementById('zizhi').style.display = "none"
document.getElementsByClassName("zhuanzai")[0].style.display = "revert"
} else {
document.getElementById('zizhi').style.display = "none"
document.getElementsByClassName("zhuanzai")[0].style.display = "none"
}
}
})
}]);
}
function ds() {
(window.RLQ = window.RLQ || []).push(['jquery', () => {
$(document).ready(function () {
var sfdingshi = document.getElementById("sfdingshi").value
if (sfdingshi == '是') {
document.getElementById('ding-datetime').style.display = "revert"
} else {
if (sfdingshi == '否') {
document.getElementById('ding-datetime').style.display = "none"
} else {
document.getElementById('ding-datetime').style.display = "none"
}
}
})
}]);
}
function heji() {
(window.RLQ = window.RLQ || []).push(['jquery', () => {
$(document).ready(function () {
var sfdingshi = document.getElementById("sfhj").value
if (sfdingshi == '是') {
document.getElementById('hj').style.display = "revert"
document.querySelector(`select#collection`).style.display = "revert"
document.querySelector(`button.setupcolle`).style.display = `revert`
} else {
if (sfdingshi == '否') {
document.getElementById('hj').style.display = "none"
document.querySelector(`select#collection`).style.display = "none"
document.querySelector(`button.setupcolle`).style.display = `none`
} else {
document.getElementById('hj').style.display = "none"
document.querySelector(`select#collection`).style.display = "none"
document.querySelector(`button.setupcolle`).style.display = `none`
}
}
})
}]);
}
function giz() {
(window.RLQ = window.RLQ || []).push(['jquery', () => {
$(document).ready(function () {
var sfguize = document.getElementById('guize').checked
if (sfguize == true) {
document.getElementById('btn').disabled = false
document.getElementById('btn').style.background = "#37c8f7"
document.getElementById('btn').style.color = "#ffffff"
} else {
document.getElementById('btn').disabled = true
document.getElementById('btn').style.background = "#e5e9ef"
document.getElementById('btn').style.color = "#99a2aa"
}
})
}]);
}
</script> <script>
var toolbarOptions = [
// remove formatting button
];
/*var quill = new Quill('#editor', {
modules: {
toolbar: toolbarOptions
},
theme: 'snow'
});*/
function quillGetHTML(inputDelta) {
var tempCont = document.createElement("div");
(new Quill(tempCont)).setContents(inputDelta);
return tempCont.getElementsByClassName("ql-editor")[0].innerHTML;
}
</script> <style>
.editor {
line-height: normal !important;
height: 750px;
}
.ql-snow .ql-tooltip[data-mode=link]::before {
content: "请输入链接地址:";
}
.ql-snow .ql-tooltip.ql-editing a.ql-action::after {
border-right: 0px;
content: '保存';
padding-right: 0px;
}
.ql-snow .ql-tooltip[data-mode=video]::before {
content: "请输入B站视频BV号:";
}
.ql-snow .ql-picker.ql-header .ql-picker-label::before,
.ql-snow .ql-picker.ql-header .ql-picker-item::before {
content: '文本';
}
.ql-snow .ql-picker.ql-header .ql-picker-label[data-value="1"]::before,
.ql-snow .ql-picker.ql-header .ql-picker-item[data-value="1"]::before {
content: '标题1';
}
.ql-snow .ql-picker.ql-header .ql-picker-label[data-value="2"]::before,
.ql-snow .ql-picker.ql-header .ql-picker-item[data-value="2"]::before {
content: '标题2';
}
.ql-snow .ql-picker.ql-header .ql-picker-label[data-value="3"]::before,
.ql-snow .ql-picker.ql-header .ql-picker-item[data-value="3"]::before {
content: '标题3';
}
.ql-snow .ql-picker.ql-header .ql-picker-label[data-value="4"]::before,
.ql-snow .ql-picker.ql-header .ql-picker-item[data-value="4"]::before {
content: '标题4';
}
.ql-snow .ql-picker.ql-header .ql-picker-label[data-value="5"]::before,
.ql-snow .ql-picker.ql-header .ql-picker-item[data-value="5"]::before {
content: '标题5';
}
.ql-snow .ql-picker.ql-header .ql-picker-label[data-value="6"]::before,
.ql-snow .ql-picker.ql-header .ql-picker-item[data-value="6"]::before {
content: '标题6';
}
.ql-snow .ql-picker.ql-font .ql-picker-label::before,
.ql-snow .ql-picker.ql-font .ql-picker-item::before {
content: '标准字体';
}
.ql-snow .ql-picker.ql-font .ql-picker-label[data-value=serif]::before,
.ql-snow .ql-picker.ql-font .ql-picker-item[data-value=serif]::before {
content: '衬线字体';
}
.ql-snow .ql-picker.ql-font .ql-picker-label[data-value=monospace]::before,
.ql-snow .ql-picker.ql-font .ql-picker-item[data-value=monospace]::before {
content: '等宽字体';
}
.ql-toolbar.ql-snow+.ql-container.ql-snow {
height: 230;
}
.ql-editor {
background: #ffffffb8;
}
.ql-toolbar.ql-snow {
background: #ffffff;
}
.ql-snow .ql-editor h2 {
margin-top: 0;
margin-bottom: .5em;
color: rgba(0, 0, 0, .85);
font-weight: 500;
display: block;
text-align: left;
font-size: 1.5em;
background: #fff0;
border-radius: 0px;
margin-block-start: 0.83em;
margin-block-end: 0.83em;
margin-inline-start: 0px;
margin-inline-end: 0px;
}
div#Info {
position: fixed;
top: 79px;
width: 50%;
right: 0;
right: 0;
left: 0;
margin: auto;
z-index: 6;
}
.suc-img {
background: url(https://patchwiki.biligame.com/images/seerwar/7/7e/6aohbs5d3afbw6edba2jxilpna97a6i.png);
height: 299px;
width: 309px;
display: inline-block;
text-align: center;
}
.suc-title {
text-align: center;
font-size: 25px;
}
.suc-btus {
margin-bottom: 10px;
}
.anniu {
border: 1px solid #bdbdbd;
border-radius: 4px;
width: 132px;
margin-top: 11px;
text-align: center;
background: #ffffff;
padding-top: 10px;
padding-bottom: 7px;
padding-left: 7px;
padding-right: 7px;
margin-right: 11px;
display: inline-block;
cursor: pointer;
}
.anniu:hover {
background: #009edd;
color: #ffffff;
}
div#BWIKIPopUp {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-pack: center;
-ms-flex-pack: center;
justify-content: center;
width: 100%;
height: 100%;
position: fixed;
top: 0;
left: 0;
font-size: 14px;
background: rgba(0, 0, 0, .5);
z-index: 10010;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
}
div#BWIKIwindow {
-webkit-box-sizing: border-box;
box-sizing: border-box;
width: 820px;
min-height: 430px;
background: #fff;
border-radius: 8px;
padding: 52px 65px 29px 92px;
position: relative;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
button.fankui:hover {
background-color: #ecf9fe;
}
button.fankui {
display: inline-block;
height: 40px;
font-size: 14px;
border-radius: 42px;
text-align: center;
vertical-align: middle;
width: 120px;
border: rgba(255, 255, 255, 0);
cursor: pointer;
line-height: 40px;
border: 1px solid #e3e5e7;
background-color: #fff;
color: #37c8f7;
border-color: #37c8f7;
margin-left: 10px;
overflow: hidden;
}
.fankuilogo {
background: url(https://patchwiki.biligame.com/images/seerwar/6/65/rfo3romyyrqqvuk9vshdzx0jzzgvmo7.svg);
width: 114px;
height: 44px;
margin-left: 10px;
}
</style> <script>
function getmodenValue() {
// 获取form元素
var form = document.forms['Publishingmode'];
// 获取所有名为'gender'的单选框 var radios = form.elements['gender'];
// 遍历单选框,查找选中的项
for (var i = 0; i < radios.length; i++) {
if (radios[i].checked) {
window.modenValue = radios[i].value;
switch (modenValue) {
case `直发模式`: {
document.querySelector(`tr.submissionpartition`).style.display = `none`;
document.querySelector(`tr.type`).style.display = `none`;
document.querySelector(`tr.author`).style.display = `none`;
document.querySelector(`tr.role`).style.display = `none`;
document.querySelector(`tr.time`).style.display = `none`;
document.querySelector(`tr.biliname`).style.display = `none`;
document.querySelector(`tr.biliuid`).style.display = `none`;
document.querySelector(`imgs-cover`).style.display = `none`;
break;
}
case `投稿模式`: {
document.querySelector(`tr.submissionpartition`).style.display = ``;
document.querySelector(`tr.type`).style.display = ``;
document.querySelector(`tr.author`).style.display = ``;
document.querySelector(`tr.biliname`).style.display = ``;
document.querySelector(`tr.biliuid`).style.display = ``;
document.querySelector(`tr.role`).style.display = ``;
break;
}
}
break; // 找到后跳出循环
}
}
}
function base64ConvertFile(urlData, filename) { // 64转file
if (typeof urlData != 'string') {
console.log("urlData不是字符串");
return;
}
var arr = urlData.split(','), type = arr[0].match(/:(.*?);/)[1],
fileExt = type.split('/')[1], bstr = atob(arr[1]), n = bstr.length,
u8arr = new Uint8Array(n);
if (!filename) filename = "image";
while (n--) {
u8arr[n] = bstr.charCodeAt(n);
}
return new File([u8arr], `${filename}.${fileExt}`, { type });
}
function getApi(url, callback = false, callbackE = false) {
let ajax = new XMLHttpRequest()
if (!callback) {
ajax.open("GET", url, false)
ajax.send()
let json = JSON.parse(ajax.responseText)
return json
}
ajax.open("GET", url)
ajax.send()
ajax.onreadystatechange = function () {
if (ajax.readyState == 4) {
if (ajax.status == 200) {
callback(ajax.responseText)
}
else if (ajax.status == 404 && callbackE) {
callbackE(true)
}
}
}
}
function postFdApi(url, fd, isParse = true) {
let ajax = new XMLHttpRequest()
ajax.open("POST", url, false)
ajax.send(fd)
if (!isParse) {
return ajax.responseText
}
let json = JSON.parse(ajax.responseText)
return json
}
</script> <style>
.ql-container .qlbt-selection-line.qlbt-selection-line-left::before {
position: absolute;
left: -2px;
top: -2px;
content: ;
width: 5px;
height: 5px;
background-color: #0589f3;
border-radius: 5px;
}
.ql-container .qlbt-selection-line.qlbt-selection-line-right::before {
position: absolute;
right: -2px;
bottom: -3px;
content: ;
width: 5px;
height: 5px;
background-color: #0589f3;
border-radius: 5px;
}
.quill-better-table-wrapper {
overflow-x: auto;
}
table.quill-better-table {
table-layout: fixed;
border-collapse: collapse;
}
table.quill-better-table td {
border: 1px solid #000;
padding: 2px 5px;
}
.qlbt-operation-menu {
background-color: #fff;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
font-size: 14px;
z-index: 100;
overflow: hidden;
}
.qlbt-operation-menu .qlbt-operation-menu-dividing {
height: 1px;
background-color: #efefef;
}
.qlbt-operation-menu .qlbt-operation-menu-subtitle {
color: #999;
font-size: 14px;
padding: 5px 16px;
}
.qlbt-operation-menu .qlbt-operation-color-picker {
display: flex;
align-items: center;
flex-wrap: wrap;
padding: 0 16px 10px;
background-color: #fff;
overflow: hidden;
}
.qlbt-operation-menu .qlbt-operation-color-picker .qlbt-operation-color-picker-item {
width: 20px;
height: 20px;
border: 1px solid #595959;
margin-right: 5px;
margin-bottom: 5px;
cursor: pointer;
}
.qlbt-operation-menu .qlbt-operation-menu-item {
display: flex;
align-items: center;
padding: 10px 16px;
background-color: #fff;
cursor: pointer;
color: #595959;
overflow: hidden;
text-overflow: ellipsis;
}
.qlbt-operation-menu .qlbt-operation-menu-item:hover {
background-color: #efefef;
}
.qlbt-operation-menu .qlbt-operation-menu-item .qlbt-operation-menu-icon {
margin-right: 8px;
height: 20px;
width: 20px;
font-size: 0;
}
.qlbt-col-tool {
position: absolute;
display: flex;
align-items: flex-end;
overflow: hidden;
z-index: 99;
height: 16px;
}
.qlbt-col-tool .qlbt-col-tool-cell {
position: relative;
background-color: #fff;
border-top: 1px solid #000;
border-right: 1px solid #000;
border-bottom: 1px solid #000;
}
.qlbt-col-tool .qlbt-col-tool-cell:first-child {
border-left: 1px solid #000;
}
.qlbt-col-tool .qlbt-col-tool-cell-holder {
position: absolute;
right: -1px;
top: 0;
bottom: 0;
z-index: 3;
width: 1px;
background-color: transparent;
cursor: ew-resize;
}
.qlbt-col-tool .qlbt-col-tool-cell-holder:hover {
background-color: #0589f3;
}
.qlbt-col-tool .qlbt-col-tool-cell-holder::before {
content: "";
position: absolute;
top: 0;
left: -6px;
display: block;
width: 8px;
height: 100%;
}
.qlbt-col-tool .qlbt-col-tool-cell-holder::after {
content: "";
position: absolute;
top: 0;
right: -6px;
display: block;
width: 8px;
height: 100%;
}
.xuankuang {
border: 2px dashed #717171;
margin-top: 10px;
padding-top: 10px;
padding-bottom: 10px;
padding-left: 10px;
padding-right: 10px;
}
</style> <script>
function removeColgroupsRegex(htmlString) {
// 使用正则表达式替换 <colgroup>...</colgroup>
// 注意:这个正则表达式可能无法处理所有复杂情况,比如嵌套标签或属性中的引号
var cleanedHtml = htmlString.replace(/<colgroup\b[^>]*>(.*?)<\/colgroup>/gi, function (match, capture) {
// 这里我们简单地返回空字符串来移除整个匹配项
// 但如果你需要保留 <colgroup> 之间的文本(不含标签),可以返回 capture
return ;
});
// 清理可能的前导或尾随空白字符 cleanedHtml = cleanedHtml.trim();
return cleanedHtml;
}
function removeColgroupsRegex1(htmlString) {
// 使用正则表达式替换 <tbody>...</tbody>
// 注意:这个正则表达式可能无法处理所有复杂情况,比如嵌套标签或属性中的引号
var cleanedHtml = htmlString.replace(/<tbody\b[^>]*>(.*?)<\/tbody>/gi, function (match, capture) {
// 这里我们简单地返回空字符串来移除整个匹配项
// 但如果你需要保留 <tbody> 之间的文本(不含标签),可以返回 capture
return capture.trim();
});
// 清理可能的前导或尾随空白字符 cleanedHtml = cleanedHtml.trim();
return cleanedHtml; }
function Submittodatawikismall(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r) {
(window.RLQ = window.RLQ || []).push(['jquery', () => {
$(document).ready(function () {
var tit = p //当前页面名称
var dqdz = mw.config.values.wgGameName //当前站点名称
//alert("不存在!");
var sj = {}
sj.code = 200; //状态
sj.pagename = p;//页面名称
sj.pic = q;//图片封面
sj.images = r;//最大图片数
sj.vc = a; //vc号
sj.title = b;//标题
sj.type = c;//类型
sj.tname = d;//分区
sj.mode = e;//模式
sj.author = f;//作者
sj.biliname = g;//B站昵称
sj.biliuid = h;//B站UID
sj.role = i;//角色
sj.ugc_season = j;//合集
sj.ugc_seasonid = o;//合集id
sj.originalstatement = k;//自制声明
sj.source = l;//来源
sj.sourceaddress = m;//来源地址
sj.time = n; //投稿时间
var nb = new NGBASE()
//this.nb.save(tit+`_`+dqdz, sj)
nb.save(`info/${tit}_${dqdz}`, sj).then(() => {
//alert("写入成功!")
Submittodatawikibig(a, b, f, n, e, p, q)
sitelist()
})
});
}]);
}
function Submittodatawikibig(a, b, c, d, e, f, g) {
(window.RLQ = window.RLQ || []).push(['jquery', () => {
$(document).ready(function () {
var dz = 'data' //目标站点名称
var dqdz = mw.config.values.wgGameName //当前站点名称
$.get(`https://wiki.biligame.com/${dz}/api.php?action=parse&format=json&title=用户讨论:GLOBAL/alltginfo_${dqdz}.json`).then(function (result233) {
//result = (new Function('return ' + result))();
if (parseInt(result233.parse.pageid) > 0) { //判断页面存在
//alert("存在!");
var nb = new NGBASE()
nb.read(`alltginfo_${dqdz}`).then((res) => {
if (res.list == undefined) { //当元素list不存在时
res.list = []
res.list[res.list.length] = { "vc": a, "title": b, "author": c, "time": d, "mode": e, "pagename": f, "pic": g }
var nb = new NGBASE()
//this.nb.save(tit+`_`+dqdz, sj)
nb.save(`alltginfo_${dqdz}`, res).then(() => {
//alert("写入成功!-3")
})
} else { //当元素lest存在时
if (res.list.indexOf(f) == -1) { //当列表里不存在该稿件时
res.list[res.list.length] = { "vc": a, "title": b, "author": c, "time": d, "mode": e, "pagename": f, "pic": g }
var nb = new NGBASE()
nb.save(`alltginfo_${dqdz}`, res).then(() => {
//alert("写入成功!-2")
})
}
}
//alert(res) //保存的内容
//console.log(res)
})
} else { //判断页面不存在
//alert("不存在!");
var sj = {}
sj.list = []
sj.list[sj.list.length] = { "vc": a, "title": b, "author": c, "time": d, "mode": e, "pagename": f, "pic": g }
var nb = new NGBASE()
//this.nb.save(tit+`_`+dqdz, sj)
nb.save(`alltginfo_${dqdz}`, sj).then(() => {
//alert("写入成功!")
})
}
})
}); }]);
}
function sitelist() {
(window.RLQ = window.RLQ || []).push(['jquery', () => {
$(document).ready(function () {
var dz = 'data' //目标站点名称
var dqdz = mw.config.values.wgGameName //当前站点名称
var sitename
let str = mw.config.values.wgSiteName;
let separatorIndex = str.indexOf("_BWIKI_"); // 找到分隔符的位置
let sitelogo = document.querySelector("img.pic-logo").src;
if (separatorIndex !== -1) { // 确保找到了分隔符
let i = str.slice(0, separatorIndex); // 提取从开头到分隔符之前的字符串
sitename = i;
}
$.get(`https://wiki.biligame.com/${dz}/api.php?action=parse&format=json&title=用户讨论:GLOBAL/user_wikisitelist.json`).then(function (result233) {
//result = (new Function('return ' + result))();
if (parseInt(result233.parse.pageid) > 0) { //判断页面存在
//alert("存在!");
var nb = new NGBASE()
nb.read(`user_wikisitelist`).then((res) => {
function containsSitename(arr, sitename) {
for (let i = 0; i < arr.length; i++) {
if (arr[i].sitename === sitename) {
return true; // 如果找到,返回true
}
}
return false; // 如果没有找到,返回false
}
if (res.site == undefined) { //当前站点在site不存在时
res.site = []
res.site[res.site.length] = { "sitename": dqdz, "sitename_zh": sitename, "siteicon": mw.config.values.wgBiliIcon, "sitelogo": sitelogo }
var nb = new NGBASE()
//this.nb.save(tit+`_`+dqdz, sj)
nb.save(`user_wikisitelist`, res).then(() => {
//alert("写入成功!-3")
})
} else { //当前站点在site存在时
if (containsSitename(res.site, `${sitename}`) == false) { //当列表里不存在时
res.site[res.site.length] = { "sitename": dqdz, "sitename_zh": sitename, "siteicon": mw.config.values.wgBiliIcon, "sitelogo": sitelogo }
var nb = new NGBASE()
nb.save(`user_wikisitelist`, res).then(() => {
//alert("写入成功!-2")
})
}
}
//alert(res) //保存的内容
//console.log(res)
})
} else { //判断页面不存在
//alert("不存在!");
var sj = {}
sj.site = []
sj.site[sj.site.length] = { "sitename": dqdz, "sitename_zh": sitename, "siteicon": mw.config.values.wgBiliIcon, "sitelogo": sitelogo }
var nb = new NGBASE()
//this.nb.save(tit+`_`+dqdz, sj)
nb.save(`user_wikisitelist`, sj).then(() => {
//alert("写入成功!")
})
}
})
}); }]); }
</script> <script>
//封面选择器
function img1cover() {
var file = document.getElementById("imageLoader").files[0];
var canvas = document.getElementById('imageCanvas');
var ctx = canvas.getContext('2d');
var reader = new FileReader();
reader.onload = function (event) {
var img = new Image();
img.onload = function () {
var scaleFactor = Math.min(300 / img.width, 200 / img.height);
canvas.style.zoom = scaleFactor;
var size = file.size;
var sizes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
var i = Math.floor(Math.log(size) / Math.log(1024));
var d = (size / Math.pow(1024, i)).toPrecision(3) + ' ' + sizes[i];
//document.getElementById("imgeSize").innerHTML = d;
var maxWidth = (img.width > 5000) ? img.width / 3 : img.width;
var maxHeight = (img.height > 5000) ? img.height / 3 : img.height;
drawImage(canvas, ctx, img, maxWidth, maxHeight);
};
img.src = event.target.result;
};
reader.readAsDataURL(file);
}
//var imageObject = null;
function drawImage(canvas, ctx, img, maxWidth, maxHeight) {
var canvasWidth = Math.min(maxWidth, img.width);
var canvasHeight = Math.min(maxHeight, img.height);
canvas.width = canvasWidth;
canvas.height = canvasHeight;
ctx.drawImage(img, 0, 0, canvasWidth, canvasHeight);
}
function base64ConvertFile(urlData, filename) { // 64转file
if (typeof urlData != 'string') {
console.log("urlData不是字符串");
return;
}
var arr = urlData.split(','), type = arr[0].match(/:(.*?);/)[1],
fileExt = type.split('/')[1], bstr = atob(arr[1]), n = bstr.length,
u8arr = new Uint8Array(n);
if (!filename) filename = "image";
while (n--) {
u8arr[n] = bstr.charCodeAt(n);
}
return new File([u8arr], `${filename}.${fileExt}`, { type });
}
//插入视频替换
function replaceIframeWithWidget(htmlContent) {
// 定义要搜索的<iframe>的正则表达式,并确保它可以匹配你给出的格式
const iframeRegex = /<iframe class="ql-video" frameborder="0" allowfullscreen="true" src="https:\/\/player.bilibili.com\/player.html\?bvid=([^"]+)&cid=&page=1"><\/iframe>/g;
// 替换函数,它将使用匹配的iframe的bvid和page属性来生成新的字符串
const replacer = (match, bvid) => {
return `
`;
};
// 使用正则表达式和替换函数来替换所有的<iframe>标签 return htmlContent.replace(iframeRegex, replacer); }
</script> <script>
//(function () { var t = function () { window.jQuery && window.mw ? $ready() : window.setTimeout(t, 100); }; t(); })();
</script>

沪公网安备 31011002002714 号