Greasy Fork is available in English.
为维基编辑器增加新功能
当前为
// ==UserScript==
// @name bangumi-wiki-editer-enhance
// @namespace rabbitohh
// @version v1.0.0
// @description 为维基编辑器增加新功能
// @author rabbitohh
// @match *://bgm.tv/subject/*
// @match *://bangumi.tv/subject/*
// @match *://chii.in/subject/*
// @icon https://bgm.tv/img/favicon.ico
// @license MIT
// @grant none
// ==/UserScript==
function convertToISBN13(isbn)
{
isbn = isbn.replace(/[^0-9Xx]/g, "");
if (isbn.length === 13)
{
return isbn;
}
else if (isbn.length === 10)
{
const base = "978" + isbn.slice(0, -1);
let sum = 0;
for (let i = 0; i < base.length; i++)
{
sum += parseInt(base[i]) * (i % 2 === 0 ? 1 : 3);
}
const checkDigit = (10 - (sum % 10)) % 10;
return base + checkDigit;
}
else
{
return 0;
}
}
function ISBNcvt(isbn)
{
var ISBN = isbn.next().val();
ISBN = convertToISBN13(ISBN);
if(ISBN==0) return '转换失败!';
isbn.next().val(ISBN);
return '转换成功!';
}
function work1()
{
var isbn = $('[value="ISBN"]');
var $cvtbutton = $('<button><i class="fas fa-hammer"></i></button>');
$cvtbutton.css({'width': '16px',
'height':'16px',
'border-radius': '50%',
'border': 'solid 1.5px #7a8ca8',
'align-items': 'center',
'justify-content': 'center',
'background-color': '#afc9f0',
'font-size': '8px',
'color': 'white',
'box-shadow': '0 4px 8px rgba(0, 0, 0, 0.2)',
'padding': '0',});
isbn.next().after($cvtbutton);
$cvtbutton.on('click', function(){
event.preventDefault();
alert(ISBNcvt(isbn));
});
}
(function() {
var link = document.createElement('link');
link.rel = 'stylesheet';
link.href = 'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css';
document.head.appendChild(link);// Font Awesome CDN
work1()
})();