Animesong

いわゆるコピペを可能とするアレ

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name        Animesong
// @namespace   https://twitter.com/akameco
// @description いわゆるコピペを可能とするアレ
// @include     http://www.jtw.zaq.ne.jp/animesong/*
// @version     1
// @grant       none
// ==/UserScript==

// enable focus text
function enableCopyText() {
  // set attributes for body 
  document.body.setAttribute("oncontextmenu","return true");
  document.body.setAttribute("onselectstart","return true");
}

// select all textarea
function selectText(c) {
  let element= document.querySelector(c);
  // create range
  let rng = document.createRange();
  rng.selectNodeContents(element);
  // add range for the selected regions
  window.getSelection().addRange(rng);
}

// create new button
function createCopyButton() {
  let button = document.createElement("button");
  // set text 
  button.innerHTML = "選択";
  button.style.margin = "0px 0px 10px 0px";
  button.style.borderTop = "1px solid #ccc";
  button.style.borderRight = "1px solid #999";
  button.style.borderBottom = "1px solid #999"; 
  button.style.borderLeft = "1px solid #ccc";
  button.style.padding = "3px 12px";
  button.style.cursor = "pointer";
  button.style.color = "#666";

  button.addEventListener("click",function(){selectText(".b")},false);
  let frame = document.querySelector("tbody");
  frame.appendChild(button);
  // swap elements
  button.parentNode.insertBefore(button,button.parentNode.firstChild);

}

window.onload = function () {
  setTimeout(function() {
    enableCopyText(); 
    createCopyButton();
  }, 10);
}