kogam22 / Wuxia World - Copy Chapters

// ==UserScript==
// @name         Wuxia World - Copy Chapters
// @namespace    http://wuxiaworld.com
// @version      0.2
// @description  This Script Places A Copy Button On The Top Of Webpage, Which Copies The Current Chapter Content When Clicked.
// @author       kogam22
// @license      MIT
// @grant        none
// @require      http://code.jquery.com/jquery-3.3.1.js
// @match        https://www.wuxiaworld.com/novel*
// ==/UserScript==


(function()
{
    var x = $(".fr-view p").length;
    var a = document.createElement("button"); a.id = "copy"; a.innerText = "Copy";
    var c = document.getElementsByTagName('h4')[1]; c.appendChild(a);
    $("#copy")
        .css({'background-color':'#44c767','-moz-border-radius':'15px','-webkit-border-radius':'15px','border-radius':'15px','border':'1px solid #18ab29','display':'inline-block',
              'cursor':'pointer','color':'#ffffff','font-family':'Arial','font-size':'16px','font-weight':'bold','padding':'8px 13px','text-decoration':'none','marginLeft':'350px'
            })
        .click(function (z)
            {
                var i = 0; var d = document.createElement("textarea"); c.appendChild(d); d.value = '';
                while(i<=x){ d.value += $(".fr-view p:eq("+i+")").text() + "\n\n"; i++; }
                d.select(); document.execCommand("copy");
                c.removeChild(d);
            });
})();