TPB Torrent Downloads

Piratebay download via torrents

当前为 2019-01-03 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name TPB Torrent Downloads
  3. // @namespace pxgamer
  4. // @version 0.5.0
  5. // @description Piratebay download via torrents
  6. // @author pxgamer
  7. // @include *thepiratebay.org/*
  8. // @require https://code.jquery.com/jquery-1.12.4.min.js
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. (function () {
  13. 'use strict';
  14.  
  15. const userPreferredCache = 'cache_1';
  16.  
  17. const preferredCaches = {
  18. cache_1: {
  19. name: 'BTCache',
  20. url: 'http://btcache.me/torrent/',
  21. end: ''
  22. },
  23. cache_2: {
  24. name: 'Torrage',
  25. url: 'https://torrage.info/torrent.php?h=',
  26. end: ''
  27. },
  28. cache_3: {
  29. name: 'iTorrents',
  30. url: 'https://itorrents.org/torrent/',
  31. end: '.torrent'
  32. }
  33. };
  34.  
  35. // Download image
  36. const dataURI = 'iVBORw0KGgoAAAANSUhEUgAAAAwAAAALCAYAAABLcGxfAAAACXBIWXMAAAsSAAALEgHS3X78AAABfklEQVQokWWQzUsbURRHzxtfkknSYq2UKNaiYncVrdBCUAoKKuKi4EKLbioqbrpp9/07unalG1Faa0EoboQoBT+QoKAgook4mMzEySRqJvO60UjihQsXfudwL1cAhOt+aKGal05j0wudiiq6Hnv/tj571pdZAAlQW/8k8vV7jz4QDVfyoKD9XXzas3gQkFWkixqJzGMeAL8sjRLAUSJvu5C0yrkrR7H45xoV9HllQupW3ORdSN5tMPMwG1NYFy6epUCXqiT4u5bmNCH0i7wgdwlGFowr8AcFskbiKkUhEHrL+6V5TVMpqQJacmyy91t1tc6NC0oD7a6LnsAsSOSrvqcF42TE526PCgDRvzI0Nd653NwUwXTAsOHcgoQJiTTYR7uuno23OavjB+L+tqqPq68Hu5vjH6KtvqQJZyacpmEntpEJZQ8azd8TNkBJANBH10ItDc9Ohwc7nh8bRRZ+ru+Hc4dvUr+mS18qEwDCn/4KXyC4mcva27cLAzOV+X9eUpMXhNIxOAAAAABJRU5ErkJggg==';
  37.  
  38. function getHash(element) {
  39. return $(element).attr('href').split(":")[3].split("&")[0];
  40. }
  41.  
  42. // Add to browsing pages
  43. $('a[title="Download this torrent using magnet"][href^="magnet:"]').each(function () {
  44. let hash = getHash(this);
  45. $(this).after('<a href="' + preferredCaches[userPreferredCache].url + hash.toUpperCase() + preferredCaches[userPreferredCache].end + '" title="Download using torrent file"><img src="data:image/png;base64,' + dataURI + '" style="width: 12px; height: 12px;" alt="Torrent link"></a>');
  46. });
  47.  
  48. // Add to torrent pages
  49. $('a[href^="magnet:"][title="Get this torrent"]').after(function () {
  50. let hash = getHash(this);
  51. $(this).after('<a style="background-image: url(data:image/png;base64,' + dataURI + '); background-position: left; background-size: contain; margin-left: 4px" href="' + preferredCaches[userPreferredCache].url + hash.toUpperCase() + preferredCaches[userPreferredCache].end + '" title="Download using torrent file">&nbsp;Download torrent file</a>');
  52. });
  53. })();