1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// ==UserScript==
// @name         Plurk To Doc
// @namespace    https://abby.md
// @version      0.1
// @description  try to take over the plurk!
// @author       You
// @match        https://www.plurk.com/p/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=plurk.com
// @grant        none
// ==/UserScript==

(function() {
    'use strict';



    let btn = document.createElement("button");
    btn.innerHTML = "Doc";
    btn.onclick = function () {
        var uid = document.querySelector("#permanent-plurk > div.plurk.cboxAnchor.divplurk.bigplurk > div.user > span > a").getAttribute("data-uid");
        var str1 = "";
        str1 += document.querySelector("#permanent-plurk > div.plurk.cboxAnchor.divplurk.bigplurk > div.content > div").innerHTML
        document.querySelectorAll("#plurk_responses  div.user > span > a").forEach((e)=>{if(e.getAttribute("data-uid")==uid){
            str1 += e.parentElement.parentElement.parentElement.querySelector(".text_holder").innerHTML
        }})
        downloadABBY("plurkDoc.html",str1)
    };
    document.querySelector("#permanent-plurk > div.plurk.cboxAnchor.divplurk.bigplurk > div.controls.clearfix > div").appendChild(btn);


})();


function downloadABBY(filename, text) {
    var pom = document.createElement('a');
    pom.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text));
    pom.setAttribute('download', filename);

    if (document.createEvent) {
        var event = document.createEvent('MouseEvents');
        event.initEvent('click', true, true);
        pom.dispatchEvent(event);
    }
    else {
        pom.click();
    }
}