get truyenchu.com.vn, lightnovel.vn text

get truyenchu, lightnovel text

// ==UserScript==
// @name         get truyenchu.com.vn, lightnovel.vn text
// @namespace    Name cmn space
// @description  get truyenchu, lightnovel text
// @version      0.1.0
// @author       You
// @match        https://truyenchu.com.vn/*
// @match        https://lightnovel.vn/truyen/*
// @grant        GM.setClipboard
// @run-at       document-idle
// ==/UserScript==

function getTextList(el=document.body){
  let txt=[];
  txt.toString=()=>txt.reduce((s,e)=>s+=e.content,'');
  const ps=document.querySelectorAll('main>div>div.chapter-content>p');
  ps.forEach(p=>{
    for (let childEl of p.children) txt.push({order:getComputedStyle(childEl).order,content:childEl.textContent});
    if (txt.length>0) {
      txt.sort((a,b)=> a.order-b.order);
      p.innerHTML=txt.toString();
      txt.splice(0,txt.length);}
  })
}

(function(){
  getTextList();
  content=document.querySelector('main>div>div.chapter-content').innerText;
  console.log(content);
  GM.setClipboard(content)
})()