Copy from Text Blaze

A simple script that addes a copy button in dashboard of Text Blaze

スクリプトをインストールするには、Tampermonkey, GreasemonkeyViolentmonkey のような拡張機能のインストールが必要です。

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

スクリプトをインストールするには、TampermonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyUserscripts のような拡張機能のインストールが必要です。

このスクリプトをインストールするには、Tampermonkeyなどの拡張機能をインストールする必要があります。

このスクリプトをインストールするには、ユーザースクリプト管理ツールの拡張機能をインストールする必要があります。

(ユーザースクリプト管理ツールは設定済みなのでインストール!)

このスタイルをインストールするには、Stylusなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus などの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus tなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

(ユーザースタイル管理ツールは設定済みなのでインストール!)

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
// ==UserScript==
// @name        Copy from Text Blaze
// @namespace   Violentmonkey Scripts
// @match       https://dashboard.blaze.today/snippet/*
// @run-at      document-end
// @grant       none
// @version     1.2
// @icon        https://dashboard.blaze.today/favicon.ico
// @author      The Myth
// @license     MIT
// @description A simple script that addes a copy button in dashboard of Text Blaze
// ==/UserScript==


const copyTorrentLinks = (output) => {
    const input = document.createElement("textarea");
    input.value = output
    document.body.appendChild(input);
    input.focus();
    input.select();
    let result = document.execCommand("copy");
    document.body.removeChild(input);
    if (result) alert("Torrent links copied to clipboard");
    else
        prompt("Failed to copy links. Manually copy from below\n\n", input.value);
};


function onClick() {
  var previewBtn = document.querySelector(
    "#root > div > div > div.MuiGrid-root.MuiGrid-item.css-1wxaqej > div > div > div > div:nth-child(2) > div > div > button:nth-child(2)"
  );
  if (previewBtn.ariaPressed == "false") {
    alert("Go to the preview section");
  } else {
    var mainDiv = document.querySelector(".form-sandbox");
    if (mainDiv) {
      let output = "\n";
      for (const element of mainDiv.childNodes) {
        if (element.childElementCount == 0) {
          output += "\n";
        } else {
          for (const insideElement of element.childNodes) {
            if (insideElement.tagName.toLowerCase() == "input") {
                if (insideElement.value=="") {
                    alert(`${insideElement.placeholder} is empty`)
                    return
                }else{
                    output+=`${insideElement.value}`
                }
            }else{
                output+=insideElement.textContent
            }
          }
          output+="\n"
        }
      }
      copyTorrentLinks(output)
    } else {
      alert("Main div not found");
    }
  }
}

function setupObserver() {
  const observer = new MutationObserver((mutations) => {
    for (const mutation of mutations) {
      if (
        mutation.target.matches(
          "#root > div > div > div.MuiGrid-root.MuiGrid-item.css-1wxaqej > div > div > div > div:nth-child(2) > div > div > button:nth-child(2)"
        )
      ) {
        var btnGroup = mutation.target.parentElement;
        var copyBtn = document.createElement("button");
        copyBtn.textContent = "Copy";
        copyBtn.type = "button";
        copyBtn.style =
          "color:#00acc0;border:1px solid;font-family:Roboto, Helvetica, Arial, sans-serif;";
        copyBtn.onclick = () => {
          onClick();
        };
        btnGroup.appendChild(copyBtn);
        observer.disconnect();
      }
    }
  });
  observer.observe(document.body, { childList: true, subtree: true });
}

setupObserver();