javascript tampermonkey-spider1
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了javascript tampermonkey-spider1相关的知识,希望对你有一定的参考价值。
// ==UserScript==
// @name New Userscript self1
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://*
// @grant none
// ==/UserScript==
/* jshint -W097 */
'use strict';
(function () {
setTimeout(function do1(){}, 8 * 1000 );
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) {
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;
var 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.getAttribute('data-src').replace(/\/1t.jpg/, '').replace(/\/1t.png/,'');
// alert(gallery1);
// var gallery1 = e2.src.replace(/\/1t.jpg/, ''); // 直接获得base64
// 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);
}
//
textarea1 = document.createElement("textarea");
// textarea1.innerHTML = text;
textarea1.setAttribute('id', textarea_id);
textarea1.setAttribute('cols', '100');
textarea1.setAttribute('rows', '10');
//
button1 = document.createElement("input");
button1.setAttribute('id', input_id);
button1.setAttribute('type', 'button');
button1.setAttribute('onclick', 'selText();');
button1.setAttribute('value', 'Copy');
button1.addEventListener('click', selText);
//
body.insertBefore(button1, body.childNodes[0]);
body.insertBefore(textarea1, body.childNodes[0]);
// body.appendChild(textarea1);
// body.appendChild(button1);
}
again1();
function selText(){
// 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);
})();
以上是关于javascript tampermonkey-spider1的主要内容,如果未能解决你的问题,请参考以下文章
javascript JavaScript isset()等效: - JavaScript
JavaScript 使用JavaScript更改CSS(JavaScript)