Greasy Fork is available in English.
在你复制磁力链接的hash时候,自动补上"magnet:?xt=urn:btih:",便于下载软件直接获取
当前为
// ==UserScript==
// @name 自动添加磁力链接前缀
// @namespace http://tampermonkey.net/
// @version 0.1
// @description 在你复制磁力链接的hash时候,自动补上"magnet:?xt=urn:btih:",便于下载软件直接获取
// @author kilin cheung
// @include *
// @match *
// @grant none
// ==/UserScript==
(function() {
'use strict';
//let p = document.getElementById('text');
document.body.addEventListener('copy', function(e) {
console.log(e.clipboardData);
console.log(window.getSelection().toString());
let selectedText = window.getSelection().toString();
if(selectedText.length == 40) {
let cont = 'magnet:?xt=urn:btih:' + selectedText;
e.clipboardData.setData('text/plain', cont);
e.preventDefault();
return;
}
});
})();