var url = window.location.href
var author = ""
var e1 = document.querySelectorAll('div#info section#tags div.tag-container')
for (var i = 0; i < e1.length; i++) {
if (e1[i].innerText.indexOf('rtists') > 0) {
var author = e1[i].innerText.replace(/Artists: /g, '').replace(/\(\d{1,4}\)/, '')
// console.log(author)
}
}
var t1 = document.querySelector('div#info section#tags')
var num_page1 = t1.nextSibling.nextSibling
num_page = num_page1.innerText.replace(/ pages/, "")
var title_en = document.querySelector('div#info h1')
var title_jp = document.querySelector('div#info h2')
var e2 = document.querySelector('div.thumb-container a.gallerythumb img')
var gallery1 = e2.src.replace(/https:\/\/\//, '').replace(/\/1t.jpg/, '')
// var tab_self
var str1 = ''
var textarea_id = 'copy3'
var input_id = 'copy4'
str1 = url + '\t' + title_en.innerText + '\t' + title_jp.innerText + '\t' + author + '\t' + num_page + '\t' + gallery1;
function again1() {
var body = document.getElementsByTagName('body')[0];
var textarea1 = document.getElementById(textarea_id)
var button1 = document.getElementById(input_id)
if (textarea1) {
body.removeChild(textarea1)
}
if (button1) {
body.removeChild(button1)
}
var textarea1 = document.createElement("textarea");
// textarea1.innerHTML = text;
textarea1.setAttribute('id', textarea_id);
textarea1.setAttribute('cols', '100');
textarea1.setAttribute('rows', '10');
//
var button1 = document.createElement("input");
button1.setAttribute('id', input_id);
button1.setAttribute('type', 'button');
button1.setAttribute('onclick', 'selText()');
button1.setAttribute('value', 'Copy');
//
body.insertBefore(button1, body.childNodes[0]);
body.insertBefore(textarea1, body.childNodes[0]);
}
again1()
selText = function() {
// console.clear();
textarea_id = 'copy3';
document.getElementById(textarea_id).select();
try {
if (document.execCommand('cut', false, null)) {
// if(document.execCommand('copy', false, null)){
console.log('success')
//success info
} else {
console.log('fail')
//fail info
}
} catch (err) {
console.log(err)
//fail info
}
}
var textarea1 = document.getElementById(textarea_id)
textarea1.innerHTML = str1
//此处不能用innerText,否则\n会被转换为<br>
scrollTo(0, 0)