MediaWiki:Gadget-CopyAsChatAlphabet.js:修订间差异
跳转到导航
跳转到搜索
无编辑摘要 |
小 (物灵移动页面User:物灵/vector.js至MediaWiki:Gadget-CopyAsChatAlphabet.js,不留重定向) |
||
(未显示同一用户的9个中间版本) | |||
第1行: | 第1行: | ||
var copyOption = false; |
var copyOption = false; |
||
function makeButton() { |
function makeButton() { |
||
var |
var 按钮 = document.createElement('li'); |
||
按钮.classList.add('mw-list-item'); |
按钮.classList.add('mw-list-item'); |
||
var linkOpen = document.createElement('a'); |
var linkOpen = document.createElement('a'); |
||
var linkClose = document.createElement('a'); |
var linkClose = document.createElement('a'); |
||
linkOpen.innerText = '复制聊天字母 ✗'; |
linkOpen.innerText = '复制聊天字母 ✗'; |
||
linkOpen.addEventListener("click", () |
linkOpen.addEventListener("click", function() { |
||
copyOption = true; |
copyOption = true; |
||
按钮.removeChild(linkOpen); |
|||
按钮.appendChild(linkClose); |
|||
return false; |
|||
}); |
}); |
||
linkClose.innerText = '复制聊天字母 ✓'; |
linkClose.innerText = '复制聊天字母 ✓'; |
||
linkClose.addEventListener("click", () |
linkClose.addEventListener("click", function() { |
||
copyOption = false; |
copyOption = false; |
||
按钮.removeChild(linkClose); |
|||
按钮.appendChild(linkOpen); |
|||
return false; |
|||
}); |
}); |
||
按钮.appendChild(linkClose); |
|||
return |
return 按钮; |
||
} |
} |
||
var letters = '!bpmwjqxynzDsrHN!bpmwjqxynzDsrHN!bpmwjqxynzDsrHNldtgkh45vF7Bcfualdtgkh45vF7Bcfualdtgkh45vF7BcfuaoeEAYL62T83V1i oeEAYL62T83V1i oeEAYL62T83V1i '; |
|||
$(() => { |
|||
function 聊天字母化(letter) { |
|||
var code = letter.charCodeAt(0) - 0xe020; |
|||
var caseSign = ['^', '', '~'][(code >>> 4) % 3]; |
|||
return caseSign + letters[code]; |
|||
} |
|||
document.getElementById('mw-content-text').addEventListener('copy', function(e) { |
|||
var data = e.clipboardData || window.clipboardData; |
|||
if (!data || !copyOption) |
|||
return; |
|||
var text = window.getSelection().toString(); |
|||
if (text) { |
|||
data.setData('text/plain', text.replace(/[\ue020-\ue0af]/g, 聊天字母化)); |
|||
e.preventDefault(); |
|||
} |
|||
}); |
|||
$(function() { |
|||
if (!document.querySelector('#p-views #ca-view.selected')) |
if (!document.querySelector('#p-views #ca-view.selected')) |
||
return; // 仅阅读模式生效 |
return; // 仅阅读模式生效 |
||
copyOption = true; |
copyOption = true; |
||
var checkbox = document.querySelector('#p-variants |
var checkbox = document.querySelector('#p-variants ul'); |
||
if (checkbox) { |
if (checkbox) { |
||
checkbox.appendChild(makeButton()); |
checkbox.appendChild(makeButton()); |
2023年2月9日 (四) 01:55的最新版本
var copyOption = false;
function makeButton() {
var 按钮 = document.createElement('li');
按钮.classList.add('mw-list-item');
var linkOpen = document.createElement('a');
var linkClose = document.createElement('a');
linkOpen.innerText = '复制聊天字母 ✗';
linkOpen.addEventListener("click", function() {
copyOption = true;
按钮.removeChild(linkOpen);
按钮.appendChild(linkClose);
return false;
});
linkClose.innerText = '复制聊天字母 ✓';
linkClose.addEventListener("click", function() {
copyOption = false;
按钮.removeChild(linkClose);
按钮.appendChild(linkOpen);
return false;
});
按钮.appendChild(linkClose);
return 按钮;
}
var letters = '!bpmwjqxynzDsrHN!bpmwjqxynzDsrHN!bpmwjqxynzDsrHNldtgkh45vF7Bcfualdtgkh45vF7Bcfualdtgkh45vF7BcfuaoeEAYL62T83V1i oeEAYL62T83V1i oeEAYL62T83V1i ';
function 聊天字母化(letter) {
var code = letter.charCodeAt(0) - 0xe020;
var caseSign = ['^', '', '~'][(code >>> 4) % 3];
return caseSign + letters[code];
}
document.getElementById('mw-content-text').addEventListener('copy', function(e) {
var data = e.clipboardData || window.clipboardData;
if (!data || !copyOption)
return;
var text = window.getSelection().toString();
if (text) {
data.setData('text/plain', text.replace(/[\ue020-\ue0af]/g, 聊天字母化));
e.preventDefault();
}
});
$(function() {
if (!document.querySelector('#p-views #ca-view.selected'))
return; // 仅阅读模式生效
copyOption = true;
var checkbox = document.querySelector('#p-variants ul');
if (checkbox) {
checkbox.appendChild(makeButton());
}
});