Skip to content

Instantly share code, notes, and snippets.

@olijf
Created November 18, 2023 14:57
Show Gist options
  • Save olijf/abef8c39317a8f2dd707e8a7ad2ed395 to your computer and use it in GitHub Desktop.
Save olijf/abef8c39317a8f2dd707e8a7ad2ed395 to your computer and use it in GitHub Desktop.
Greasemonkey userscript to add a download link to iTorrents caching service
// ==UserScript==
// @name BtDig.com to iTorrent
// @version 1.0
// @description Adds link to itorrent file
// @match https://btdig.com/*/*
// ==/UserScript==
function _x(STR_XPATH) {
var xresult = document.evaluate(STR_XPATH, document, null, XPathResult.ANY_TYPE, null);
var xnodes = [];
var xres;
while (xres = xresult.iterateNext()) {
xnodes.push(xres);
}
return xnodes;
}
(function() {
'use strict';
var child = _x('/html/body/center/div[1]/div/center/table/tbody/tr[4]/td[2]')
var downloadUrl = document.createElement('a')
downloadUrl.setAttribute('href', 'https://itorrents.org/torrent/' + encodeURI(window.location.pathname.split('/')[1]) + '.torrent')
downloadUrl.innerHTML = '⭳ Download from iTorrents!'
child[0].append(document.createElement('br'))
child[0].append(downloadUrl)
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment