Zebra

try to take over the world!

Verze ze dne 29. 07. 2020. Zobrazit nejnovější verzi.

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

You will need to install an extension such as Tampermonkey to install this script.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name         Zebra
// @namespace    http://tampermonkey.net/
// @version      0.1.3
// @description  try to take over the world!
// @author       HolmesZhao
// @match        *://zebra.zuoyebang.cc/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Your code here...

    function addButton(name, marginLeft, fun) {
        var txt = document.createTextNode(name);
        var btn = document.createElement('button');
        btn.className = 'mmbutton';
        btn.style = "z-index: 9999; font-size: large; position: fixed; top: 0pt; left: "+(screen.width / 4 + marginLeft)+"px;";
        btn.onclick = fun;
        btn.appendChild(txt);
        document.body.appendChild(btn);
        return btn.offsetWidth;
    };

    function getAll() {
        let trDoms = document.getElementsByTagName('tbody')[0].children;
        let all = [];
        for (let i = 0; i < trDoms.length; i++) {
            const tr = trDoms[i];
            let description = tr.children[3].innerText;
            let name = tr.children[4].innerText;
            let type = tr.children[5].innerText;
            let code = "// ";
            let res = "";
            description = "/// " + description;
            switch (type) {
                case "点击":
                    code += ("[MMEventTool postOpKey:MMEventOpKey" + name + "];");
                    break;
                case "展现":
                    code += ("[MMEventTool postStateKey:MMEventOpKey" + name + "];");
                    break;
                default:
                    break;
            }
            name = "static MMEventOpKey MMEventOpKey" + name + " = @\"" + name + "\";";

            res += description;
            res += "\n";
            res += name;
            res += "\n";
            res += code;

            all.push(res);
        }
        let copy_text = all.join("\n\n");
        let titleDom = document.getElementsByClassName('header_title')[0];
        let titleInnerHtml = titleDom.innerHTML;
        titleDom.innerHTML = titleInnerHtml + "<textarea id=\"getAllCopy\" style=\"opacity: 0;position:absolute;\">" + copy_text + "</textarea>";
        var element = document.getElementById("getAllCopy");
        element.select(); // 选择对象
        document.execCommand("Copy"); // 执行浏览器复制命令
    }

    function inject() {
        getAll();
        alert('已复制所有埋点');
    }

    window.onload = () => {
        addButton('注入脚本', 0, inject);
    }
})();