try to take over the world!
目前為
// ==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);
}
})();