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.3
  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="icon16 askFeedbackjs" data-id="[A-Z0-9]+"><i class="ka ka16 ka-magnet"><\/i><\/a>/ig;
  37. var ss_torrent = /<a data-download title="Download torrent file" href="(\/torrents\/.*-t[0-9]+\/)" class="icon16 askFeedbackjs"><i class="ka ka16 ka-arrow-down"><\/i><\/a>/ig;
  38. var matches;
  39. $.ajax({
  40. type: "GET",
  41. url: url,
  42. async: false,
  43. success: function (data) {
  44. var e = 0;
  45. while (matches = ss_title.exec(data.html)) {
  46. eMatch.titles.push(matches[1]);
  47. }
  48. while (matches = ss_magnet.exec(data.html)) {
  49. eMatch.magnets.push(matches[1]);
  50. }
  51. while (matches = ss_torrent.exec(data.html)) {
  52. eMatch.torrents.push('https://kat.cr' + matches[1]);
  53. }
  54. while (matches = ss_url.exec(data.html)) {
  55. eMatch.urls.push('https://kat.cr' + matches[1]);
  56. }
  57. },
  58. returnData: "json"
  59. });
  60. }
  61.  
  62. for (var k = 0; k < eMatch.titles.length; k++) {
  63. defined.data_list.push({
  64. title: eMatch.titles[k],
  65. magnet: eMatch.magnets[k],
  66. torrent: eMatch.torrents[k],
  67. url: eMatch.urls[k]
  68. });
  69. }
  70. console.log(defined.data_list);
  71. });
  72. })();