Animesong

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

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

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

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.

ستحتاج إلى تثبيت إضافة مثل Stylus لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتتمكن من تثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

(لدي بالفعل مثبت أنماط للمستخدم، دعني أقم بتثبيته!)

// ==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);
}