Skip to content

Instantly share code, notes, and snippets.

@xioxin
Last active April 19, 2024 11:57
Show Gist options
  • Star 21 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xioxin/588cfcbc9d4a50e797c1cacb0a620a03 to your computer and use it in GitHub Desktop.
Save xioxin/588cfcbc9d4a50e797c1cacb0a620a03 to your computer and use it in GitHub Desktop.
Eh磁力链助手
// ==UserScript==
// @name eh磁力链助手
// @namespace com.xioxin.EhTagMagnetHelper
// @version 0.1
// @description 在种子列表直接复制磁力链
// @author xioxin
// @include *://exhentai.org/gallerytorrents.php*
// @include *://e-hentai.org/gallerytorrents.php*
// @grant GM_setClipboard
// ==/UserScript==
async function myNotification(title,options)
{
let permission = await Notification.requestPermission();
if(permission == 'granted'){
return new Notification(title, options);
}else{
return false;
}
}
(function() {
let tableList = document.querySelectorAll("#torrentinfo form table");
if(tableList&&tableList.length)tableList.forEach(function (table) {
let href = '';
let a = table.querySelector('a');
if(a)href = a.href;
if(!href)return;
let magnet = href.replace(/.*?([0-9a-f]{40}).*$/i,"magnet:?xt=urn:btih:$1") ;
if(magnet.length != 60)return;
let insertionPoint = table.querySelector('input');
if(!insertionPoint)return;
var button = document.createElement("input");
button.type = "button";
button.value = "复制磁力链";
button.className = 'stdbtn';
button.onclick = function () {
GM_setClipboard(magnet);
myNotification('复制成功',{
body:magnet
});
};
insertionPoint.parentNode.insertBefore( button, insertionPoint );
})
})();
@xioxin
Copy link
Author

xioxin commented Jul 23, 2020

此处不再更新,请前往 https://github.com/EhTagTranslation/UserScripts/ 下载

@xmhwws
Copy link

xmhwws commented Apr 17, 2024

@xioxin 已经失效了,请作者大大修复一下,感激

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment