Grab All Uploads Info

Grabs a list of all uploads and their data for a certain user.

当前为 2016-06-04 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Grab All Uploads Info
  3. // @namespace PXgamer
  4. // @version 0.5
  5. // @description Grabs a list of all uploads and their data for a certain user.
  6. // @author PXgamer
  7. // @include *kat.cr/user/*/uploads/*
  8. // @grant none
  9. // ==/UserScript==
  10. /*jshint multistr: true */
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. // Defines vars
  16. var defined = {
  17. first_page: '1',
  18. last_page: $('.pages a.turnoverButton.siteButton.bigButton[rel="nofollow"]:last').text(),
  19. data_list: [],
  20. user: location.href.split('/')[4],
  21. data_type: location.href.split('/')[6]
  22. };
  23. var eMatch = { titles: [], magnets: [], torrents: [], urls: [] };
  24. if (defined.last_page === '') { defined.last_page = '1'; }
  25.  
  26. $('h2').after('<span class="siteButton bigButton grabUploadsList">Grab uploads list</span>');
  27.  
  28. $('.grabUploadsList').on('click', function() {
  29. console.log('Constructing List. Please wait...');
  30. console.info(defined);
  31.  
  32. for (var i = 1; i <= defined.last_page; i++) {
  33. var url = 'https://kat.cr/user/'+defined.user+'/uploads/'+defined.data_type+'?page=' + i;
  34. var ss_title = /<a href="\/.*-t[0-9]+.html" class="cellMainLink">(.*)<\/a>/ig;
  35. var ss_url = /<a href="(\/.*-t[0-9]+.html)" class="cellMainLink">.*<\/a>/ig;
  36. var ss_magnet = /<a data-nop title="Torrent magnet link" href="(magnet:\?xt=urn:btih:.*)" class="/ig;
  37. var ss_torrent = /<a data-download title="Download torrent file" href="(\/torrents\/.*-t[0-9]+\/)" class="/ig;
  38. var ss_delhash = /<a href="javascript: undeleteTorrent\('[0-9]+', '([A-Z0-9]+)', true\)/ig;
  39. var matches;
  40. $.ajax({
  41. type: "GET",
  42. url: url,
  43. async: false,
  44. success: function (data) {
  45. var e = 0;
  46. while (matches = ss_title.exec(data.html)) {
  47. eMatch.titles.push(matches[1]);
  48. }
  49. while (matches = ss_url.exec(data.html)) {
  50. eMatch.urls.push('https://kat.cr' + matches[1]);
  51. }
  52. if (defined.data_type == 'deleted') {
  53. while (matches = ss_delhash.exec(data.html)) {
  54. eMatch.magnets.push('magnet:?xt=urn:btih:'+matches[1]);
  55. eMatch.torrents.push('https://torcache.net/torrent/' + matches[1] + '.torrent');
  56. }
  57. }
  58. else {
  59. while (matches = ss_magnet.exec(data.html)) {
  60. eMatch.magnets.push(matches[1]);
  61. }
  62. while (matches = ss_torrent.exec(data.html)) {
  63. eMatch.torrents.push('https://kat.cr' + matches[1]);
  64. }
  65. }
  66. },
  67. returnData: "json"
  68. });
  69. }
  70.  
  71. for (var k = 0; k < eMatch.titles.length; k++) {
  72. defined.data_list.push({
  73. title: eMatch.titles[k],
  74. magnet: eMatch.magnets[k],
  75. torrent: eMatch.torrents[k],
  76. url: eMatch.urls[k]
  77. });
  78. }
  79. console.log(defined.data_list);
  80. });
  81. })();