hitomi.la url catcher

Copy shown content's URL and name to clipboard, maintained for JDownloader2. like https://URL%Packagename=name, and based nyaa magnet catcher thank you very much for based coder.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name         hitomi.la url catcher
// @version      0.1
// @description  Copy shown content's URL and name to clipboard, maintained for JDownloader2. like https://URL%Packagename=name, and based nyaa magnet catcher thank you very much for based coder.
// @author       luminisward, aPirateAnonymous.
// @license      CC0 PublicDomain
// @match        https://hitomi.la/*
// @grant        none
// @require      https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.0/clipboard.min.js
// @namespace https://greasyfork.org/users/2810
// ==/UserScript==

(function() {
  "use strict";
  function insertCheckbox() {
    var headRow = $("div.top-content");
    headRow.prepend(
      $("<tr>").append(
        $('<input type="checkbox" id="checkall" />')
          .attr("checked", true)
          .change(function() {
            $("tbody input").prop("checked", this.checked);
          })
      )
    );

    var bodyRows = $("div.gallery-content");
    bodyRows.prepend(
      $("<tr>").append($('<input type="checkbox" />').attr("checked", true))
    );
  }

  function getCheckedList() {
    var checkboxList = $("div.gallery-content");
    return $.map(checkboxList, x => true);
  }

  function getMagnetLinks() {
    var bodyRows = $("div.gallery-content div h1 a");
    var links = $.map(bodyRows, x => x.href + "#packagename=" + x.firstChild.data);
    return links.filter(link => link.includes(".html"));
  }

  /* function getName() {
    var bodyRows = $("div.gallery-content div.dj h1 a");
    return links = $.map(bodyRows, x => x.firstChild.data );
  } */

  function insertCopyButton() {//sounyuu the CopyButton to top panel
    var navBar = $("div.top-content")
    var button = document.createElement("li");
    var a = document.createElement("a");
    $(a)
      .attr("href", "#")
      .attr("id", "copyMagnet")
      .text("Copy All Links")
      .click(e => {
        e.preventDefault();
      });
    button.append(a);
    navBar[0].append(button);
  }

  insertCopyButton();
  insertCheckbox();

  new ClipboardJS("#copyMagnet", {
    text: function() {
      var links = getMagnetLinks();
      //var names = getName();
      var checkedList = getCheckedList();

      /* links = links.filter(function(val, i) {
        return checkedList[i];
      }); */
      return links.join("\n");
    }
  });
})();