Greasy Fork

Greasy Fork is available in English.

超能网

自动复制超能网文章正文

当前为 2019-07-01 提交的版本,查看 最新版本

// ==UserScript==
// @name         超能网
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  自动复制超能网文章正文
// @author       林心宇
// @match        https://www.expreview.com/*
// @exclude      https://www.expreview.com/
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Your code here...
    var post_body = document.getElementById("post_body");
    var art = '';
    var ps = post_body.getElementsByTagName('p');
    for(var i = 0 ; i<ps.length;i++){
        art += ps[i].innerText;
        art += '\n';
    }
    var artinput =document.createElement("input");
    artinput.setAttribute("type","text");
    artinput.setAttribute("id","art");
    artinput.setAttribute("value",art);
    artinput.setAttribute("readonly","readonly");
    post_body.appendChild(artinput);
    var artdocument = document.getElementById("art");
    artdocument.select();
    document.execCommand("Copy");
    alert('正文已添加到剪贴板:\n' + art);
    artinput.remove();
})();