Skip to content

Instantly share code, notes, and snippets.

@zhimiaoli
Last active June 3, 2024 15:31
Show Gist options
  • Save zhimiaoli/fc7c22a27feaa2cbf9ec4563fe860d30 to your computer and use it in GitHub Desktop.
Save zhimiaoli/fc7c22a27feaa2cbf9ec4563fe860d30 to your computer and use it in GitHub Desktop.
在bt4g.org的页面上直接显示磁力添加下载地址
// ==UserScript==
// @name bt4g Magnet direct show
// @namespace http://tampermonkey.net/
// @version 0.3
// @description 在bt4g.org的页面上直接显示磁力添加下载地址,现在仅支持详情页。
// @author lizhimiao
// @match https://bt4g.org/magnet/*
// @match https://bt4gprx.com/magnet/*
// @icon https://www.google.com/s2/favicons?domain=bt4g.org
// @grant none
// @updateURL https://gist.github.com/zhimiaoli/fc7c22a27feaa2cbf9ec4563fe860d30/raw/bt4g_Magnet_direct_show.user.js
// ==/UserScript==
(function() {
'use strict';
var linkDOM = document.querySelector("body > main > div > div:nth-child(2) > div > table:nth-child(3) > tbody > tr > th > a");
if (linkDOM) {
console.log("page sinle");
var link = document.querySelector("a[href^='\//downloadtorrentfile.com/hash\/']");
var hash = link.href.replace("https://downloadtorrentfile.com/hash/","").replace("?name","&dn");
linkDOM.href = "magnet:?xt=urn:btih:" + hash;
}
/* comment out list page function.
function appendLink(item) {
var d = document.createElement("a");
d.href=item.href;
d.target="_blank";
d.innerHTML = "🔗";
item.parentNode.insertBefore(d,item.nextSibling);
//console.log(item.href.replace("/magnet/","magnet:?xt=urn:btih:").replace("https://bt4g.org",""));
//item.href = item.href.replace("https://bt4g.org","");
console.log(item.href);
item.href = item.href.replace(/.*magnet\//,"magnet:?xt=urn:btih:");
//.replace("https\:\/\/bt4gprx\.com","");
}
var links = document.querySelectorAll("a[href^='\/magnet\/']");
links.forEach(appendLink);
*/
})();
@cleuton4k
Copy link

not work

@zhimiaoli
Copy link
Author

updated,dropped support for list page ,now only support detail page.

@Lovebragi
Copy link

I have the same problem, Bt4g used to put the file hash values in the search result page as a part of the result links, and I could easily grab them then generate full magnet links (I added a button with the magnet link beside each result). But later they changed all the hash values in the search page to encrypted strings, now I have to check the result link pages to have the right magnet link, inconveniently.

I'm not a pro, AI told me those encrypted strings cannot be reversed, what do you think?

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