新上报插件jianan
// ==UserScript==
// @name 新上报插件jianan
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author jiananchen
// @match http://*biztest.dmp.futuoa.com*
// @icon https://www.google.com/s2/favicons?sz=64&domain=segmentfault.com
// @grant none
// ==/UserScript==
(function() {
'use strict';
// Your code here...
let btn=document.createElement("img");
btn.src='https://img.alicdn.com/imgextra/i4/O1CN01lWBOlQ1NatIUxe3Hl_!!6000000001587-54-tps-140-160.apng';
btn.style.position='fixed';
btn.style.top='100px';
btn.style.width='100px';
btn.style.height='100px';
btn.onclick=function(){
//code
var nameArr=[];
var names=document.querySelectorAll("body > div > section > section > main > div > div:nth-child(4) > div.el-card__body > div > div > div.attr-content > div.attr-base > div > div:nth-child(2) > span");
for(let i of names){
nameArr.push(i.title);
}
var typeArr=[];
var types=document.querySelectorAll("body > div > section > section > main > div > div:nth-child(4) > div.el-card__body > div > div > div.attr-content > div.attr-base > div > div:nth-child(3) > span")
for(let i of types){
typeArr.push(i.innerHTML);
}
var clazzName=document.querySelector("body > div.common-app > section > section > main > div > div:nth-child(2) > div.el-card__body > div > form > div > div:nth-child(2) > div > div > div > input").value;
var version=1;
var isUrgent=document.querySelector("body > div > section > section > main > div > div:nth-child(3) > div.el-card__body > div > form > div > div:nth-child(6) > div > div > div > label.el-radio.is-disabled.is-checked > span.el-radio__input.is-disabled.is-checked > input").value;
//alert(clazzName+" "+version+" "+isUrgent+nameArr+typeArr)
var inner="";
for(let i = 0; i < nameArr.length; i++){
if(i!=0){
inner+=",";
}
inner+='\n @SerializedName("'+nameArr[i]+"\")\n val "+nameArr[i]+":String"
}
var text='class '+clazzName+'('+inner+"\n):BaseTrackEvent(event =\""+clazzName+"\",version=1,urgent="+(isUrgent==1)+")";
alert(text)
if (navigator.clipboard) {
// clipboard api 复制
navigator.clipboard.writeText(text);
} else {
var textarea = document.createElement('textarea');
document.body.appendChild(textarea);
// 隐藏此输入框
textarea.style.position = 'fixed';
textarea.style.clip = 'rect(0 0 0 0)';
textarea.style.top = '10px';
// 赋值
textarea.value = text;
// 选中
textarea.select();
// 复制
document.execCommand('copy', true);
// 移除输入框
document.body.removeChild(textarea);
}
// class ClickEvent(
// 具体tab
//@SerializedName("tab_name") // 注意混淆
//val clickTab: String) : BaseTrackEvent(event = "ClickEvent,version=1,\n urgent=")
}
document.body.append(btn);
})();