Advertisement
Guest User

pirate.html

a guest
Aug 21st, 2014
367
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 8.12 KB | None | 0 0
  1. <!DOCTYPE HTML>
  2. <html lang="en">
  3. <head>
  4.     <title></title>
  5.     <meta charset="UTF-8">
  6.  
  7.     <!-- jQuery and AJAX Cross-Origin -->
  8.     <script src="//code.jquery.com/jquery-2.1.1.min.js"></script>
  9.     <script src="//www.ajax-cross-origin.com/js/jquery.ajax-cross-origin.min.js"></script>
  10.     <script>
  11.         function get_proxies(cb) {
  12.             var proxies = [];
  13.  
  14.             $.ajax({
  15.                 crossOrigin: true,
  16.                 url: "http://proxybay.info",
  17.                 success: function(data) {
  18.                     $(data).find(".site a").each(function() {
  19.                         var proxy = {
  20.                             "name": $(this).text(),
  21.                             "url": $(this).attr("href")
  22.                         }
  23.                         proxies.push(proxy);
  24.                     });
  25.                 }
  26.             }).done(function() {
  27.                 cb(proxies);
  28.             });
  29.         }
  30.  
  31.         function parse_type(type) {
  32.             var type_str = "";
  33.             var arr = $(type).find("a");
  34.  
  35.             $.each(arr, function(index) {
  36.                 type_str += $(this).text();
  37.                 if (arr.length > 1 && index != (arr.length - 1)) {
  38.                    type_str += ", ";
  39.                 }
  40.             });
  41.  
  42.             return type_str;
  43.         }
  44.  
  45.         function parse_search_results(search_results, cb) {
  46.             var results = [];
  47.  
  48.             $.each(search_results, function(index) {
  49.                 var title = $(this).find("a.detLink").text();
  50.  
  51.                 var mag_title = "Download this torrent using magnet";
  52.                 var mag_a = $(this).find("a[title='" + mag_title + "']");
  53.                 var mag_link = $(mag_a).attr("href");
  54.  
  55.                 var seeds = $(this).find("td:nth-child(3)").text();
  56.                 var leeches = $(this).find("td:nth-child(4)").text();
  57.  
  58.                 var type = parse_type($(this).find(".vertTh"));
  59.  
  60.  
  61.                 if (title != "") {
  62.                     var data = {
  63.                         "title": title,
  64.                         "type": type,
  65.                         "mag_link": mag_link,
  66.                         "seeds": seeds,
  67.                         "leeches": leeches
  68.                     }
  69.                     results.push(data);
  70.                 }
  71.             });
  72.  
  73.             cb(results);
  74.         }
  75.  
  76.         function list_search_results(search_results, top) {
  77.             var html = "<ul>";
  78.  
  79.             $.each(search_results, function(index) {
  80.                 var res = $(this)[0];
  81.                 html += "<ul class='result'>";
  82.                 html += "   <li class='type'>[" + res.type + "]</li>";
  83.                 html += "   <li class='title'>" + res.title + "</li>";
  84.                 html += "   <li class='link'>";
  85.                 html += "       <a href='" + res.mag_link + "'>";
  86.                 html += "           torrent this";
  87.                 html += "       </a>";
  88.                 html += "   </li>";
  89.                 html += "   <li class='seeds'>";
  90.                 html +=         res.seeds + " seeds";
  91.                 html += "   </li>";
  92.                 html += "   <li class='leeches'>";
  93.                 html +=         res.leeches + " leeches";
  94.                 html += "   </li>";
  95.                 html += "</ul>";
  96.  
  97.                 if (index == top) {
  98.                     return false;
  99.                 }
  100.             });
  101.             html += "</ul>";
  102.  
  103.             if (search_results.length == 0) {
  104.                 html = "<center>";
  105.                 html += "<b>";
  106.                 html += "Opps! Cound't find anything!";
  107.                 html += "</b>";
  108.                 html += "</center>";
  109.             }
  110.  
  111.             $("div#search_results").html(html);
  112.         }
  113.  
  114.         function search_piratebay(pb_url, query, category) {
  115.             pb_url += "search/" + query + "/0/7/" + category;
  116.  
  117.             $.ajax({
  118.                 crossOrigin: true,
  119.                 url: pb_url,
  120.                 success: function(data) {
  121.                     var results = $(data).find("table#searchResult tr");
  122.                     parse_search_results(results, function(data) {
  123.                         list_search_results(data, 5);
  124.                     });
  125.                 }
  126.             });
  127.         }
  128.  
  129.         function search_options(cb) {
  130.             var checked = $("div#search_bar input:checked");
  131.             var display = $("div#search_results");
  132.             var category = checked.val();
  133.  
  134.             if (checked.length > 1) {
  135.                 display.html("Opps! you can only check 1 option!");
  136.  
  137.             } else if (checked.length == 0) {
  138.                 category = 0;
  139.  
  140.             } else {
  141.                 if (category == "hd_movie") {
  142.                     category = "207";
  143.                 } else if (category == "hd_tv") {
  144.                     category = "208";
  145.                 } else if (category == "audio") {
  146.                     category = "101";
  147.                 } else if (category == "flac") {
  148.                     category = "204";
  149.                 }
  150.  
  151.             }
  152.  
  153.             cb(category);
  154.         }
  155.  
  156.         $(document).ready(function() {
  157.             $("button#search").click(function(category) {
  158.                 var q = $("input[name='q']").val();
  159.  
  160.                 // load search results
  161.                 search_options(function(category) {
  162.                     get_proxies(function(proxies) {
  163.                         $("div#search_results").html("Loading!!");
  164.                         var proxy = proxies[0];
  165.                         search_piratebay(proxy.url, q, category);
  166.                     });
  167.                 });
  168.  
  169.             });
  170.  
  171.             $("input[name='q']").keypress(function(evnt) {
  172.                 if (evnt.keyCode == 13) {
  173.                     $("button#search").click();
  174.                 }
  175.             });
  176.         });
  177.     </script>
  178.  
  179.     <style>
  180.         body {
  181.             width: 600px;
  182.             margin-left: auto;
  183.             margin-right: auto;
  184.             font-family: Verdana, Aerial;
  185.             font-size: 0.8em;
  186.         }
  187.  
  188.         div#search_bar {
  189.             margin-top: 20px;
  190.             margin-bottom: 20px;
  191.         }
  192.  
  193.         div#search_bar button {
  194.             margin-left: 10px;
  195.         }
  196.  
  197.         div#search_results ul {
  198.             list-style-type: none;
  199.             margin: 0;
  200.             padding: 0;
  201.         }
  202.  
  203.         div#search_results ul.result {
  204.             clear: left;
  205.             overflow: none;
  206.  
  207.             margin-top: 30px;
  208.             margin-bottom: 45px;
  209.         }
  210.  
  211.         li.type {
  212.             font-size: 0.8em;
  213.         }
  214.  
  215.         li.title {
  216.             float: left;
  217.         }
  218.  
  219.         li.link {
  220.             clear: left;
  221.             float: left;
  222.             margin-right: 30px;
  223.             margin-top: 2px;
  224.  
  225.             font-size: 0.7em;
  226.         }
  227.  
  228.         li.seeds {
  229.             float: left;
  230.             margin-right: 10px;
  231.  
  232.             font-size: 0.7em;
  233.         }
  234.  
  235.         li.leeches {
  236.             float: left;
  237.  
  238.             font-size: 0.7em;
  239.         }
  240.  
  241.         a:link, a:visited {
  242.             padding-left: 5px;
  243.             padding-right: 5px;
  244.  
  245.             color: #FFF;
  246.             text-decoration: none;
  247.  
  248.             border-radius: 2px;
  249.             background-color: #777;
  250.         }
  251.  
  252.         a:hover {
  253.             color: #777;
  254.             background-color: #EEE;
  255.         }
  256.  
  257.         span.checkbox_text {
  258.             font-size: 0.7em;
  259.         }
  260.  
  261.     </style>
  262. </head>
  263. <body>
  264.     <div id="search_bar">
  265.         <input type="text" name="q"></input>
  266.         <input type="checkbox" name="hd_movie" value="hd_movie">
  267.             <span class="checkbox_text">hd movie</span>
  268.         </input>
  269.         <input type="checkbox" name="hd_tv" value="hd_tv">
  270.             <span class="checkbox_text">hd tv</span>
  271.         </input>
  272.         <input type="checkbox" name="audio" value="audio">
  273.             <span class="checkbox_text">audio</span>
  274.         </input>
  275.         <input type="checkbox" name="flac" value="flac">
  276.             <span class="checkbox_text">flac</span>
  277.         </input>
  278.         <button id="search">search</button>
  279.     </div>
  280.     <div id="search_results"></div>
  281. </body>
  282. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement