// ==UserScript==
// @name Syosetu Chapter Copy
// @namespace ultrabenosaurus.Syosetu
// @version 0.1
// @description Copy the chapter content from a Syosetu chapter page.
// @author Ultrabenosaurus
// @match https://ncode.syosetu.com/*/*/
// @grant GM.setClipboard
// @grant GM_setClipboard
// @downloadURL none
// ==/UserScript==
(function() {
'use strict';
let txtBox = document.createElement("textarea");
var btnElem = "
";
document.querySelectorAll('div#novel_color p.novel_subtitle')[0].insertAdjacentHTML("beforeend", btnElem);
var sccBtn = document.getElementById('UBsyosetuChapterCopy');
if(sccBtn){
sccBtn.addEventListener("click", UBsyosetuChapterCopy, false);
txtBox.id = "UBsyosetuChapterContent";
txtBox.name = "UBsyosetuChapterContent";
txtBox.style = "width: 0; height: 0; border: none;";
document.body.appendChild(txtBox);
txtBox.value = document.querySelectorAll('div#novel_honbun')[0].textContent;
}
sccBtn = btnElem = txtBox = null;
})();
function UBsyosetuChapterCopy() {
let txtBox = document.getElementById('UBsyosetuChapterContent');
txtBox.select();
txtBox.setSelectionRange(0, 99999);
document.execCommand("copy");
//console.log(txtBox.value);
//console.log(window.getSelection().toString());
}