Advertisement
overloop

exhentai_torrentlinks

Mar 23rd, 2013
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name        exhentai_torrentlinks
  3. // @namespace   exhentai_torrentlinks
  4. // @description exhentai_torrentlinks
  5. // @include     http://exhentai.org/g/*
  6. // @require     http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js
  7. // @version     1
  8. // ==/UserScript==
  9.  
  10. String.prototype.indexOfAll = function(substr) {
  11.     var i = 0;
  12.     var indexes = [];
  13.     while(i>-1) {
  14.         i = this.indexOf(substr,i);
  15.         if (i>-1) {
  16.             indexes.push(i);
  17.             i++;
  18.         }
  19.     }
  20.     return indexes;
  21. }
  22.  
  23. function onTorrents(data) {
  24.     //cut all tables from ajax responce and append them to description div (1 table - one torrent link)
  25.     var i = 0, tb = data.indexOfAll('<table'), te = data.indexOfAll('</table'); // table_begin, table_end
  26.     for (var i in tb)
  27.     {
  28.         var t = data.substr(tb[i],te[i]-tb[i]+8).replace('width:99%','border: 1px solid #34353B;');
  29.         $('#taglist').append(t);
  30.     }
  31. }
  32.  
  33. window.onload = function() {
  34.     //get torrents page using ajax
  35.     var url = $("#gd5 a")[2].getAttribute('onclick').match(/http:\/\/[0-9a-z.?=\/&]*/);
  36.     $.ajax({url: url, success: onTorrents, method: 'GET'});
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement