preface

Front-end time to see the world of big boss cloud out of a nuggets lottery visualization plug-in (I use the oil monkey), feel very interesting, copy the code, access, use a few days, feel very good, research, change a little style, add some functions

Posted to oilmonkey address

No more words, just look at the effect

The added functions are as follows:

  • After successful check-in, the number of consecutive check-in days and cumulative check-in days will be displayed
  • Display ore quantity and lotto times
  • Optimization of style

Interested friends can optimize again, attach the code

// ==UserScript==
// @name nuggets check-in + visualization smart lottery
// @namespace http://tampermonkey.net/
/ / @ version 0.1
// @description try to take over the world!
// @author
// @icon https://www.google.com/s2/favicons?domain=juejin.cn
// @grant none
// @include https://juejin.cn/*
// ==/UserScript==

(function() {
    'use strict';

    console.log("Roving Monkey Script: Automatic check-in for Gold digging + Visual intelligent lottery");

    const styleContent = ` ._jj_draw_container { position:fixed; top: 80px; right: 0; z-index: 9999; Background - color: rgba (0,0,0,0.6); padding: 20px; } ._jj_button { padding: 6px; background-color: #1e80ff; color: #fff; border-radius: 4px; text-align: center; vertical-align: middle; border: 1px solid transparent; font-weight: 700; letter-spacing: 1em; text-indent: 1em; cursor: pointer; } ._jj_btn_sign_in{ background-color:#e8f3ff ! important; color:#1e80ff ! important; }._jj_button:hover {opacity: 0.8; } table._jj_hovertable thead { text-align: center; font-size: 16px; font-weight: 700; color:#333; } table._jj_hovertable { font-family: verdana, arial, sans-serif; font-size: 11px; color: #d25f00; border-width: 1px; border-color: #999999; border-collapse: collapse; } table._jj_hovertable th { background-color: #c3dde0; border-width: 1px; padding: 8px; border-style: solid; border-color: #a9c6c9; } table._jj_hovertable tr { background-color: #fff; } table._jj_hovertable td { border-width: 1px; padding: 8px; border-style: solid; border-color: #a9c6c9; } ._jj_button_close{ font-size: 20px; font-weight: 700; color: #FFF; } .__jj_dialog_title{ display: flex; } .__jj_dialog_title_left{ flex:1; font-size: 14px; color: #fff; } .__jj_dialog_title_left span{ color: #1e80ff; font-size:20px; font-weight: 700; } .__jj_dialog_title_right{ width: 30px; } `;


    const htmlContent = ` 
      
function appendStyle(text) { const styleEl = document.createElement('style'); styleEl.textContent = text; document.head.appendChild(styleEl); } function appendHTML(htmlContent) { const htmlEl = document.createElement('div'); htmlEl.id = "_jj_draw_container"; htmlEl.className = "_jj_draw_container"; htmlEl.innerHTML = htmlContent; document.body.appendChild(htmlEl); getCurPoint(); } appendStyle(styleContent); appendHTML(htmlContent); let lotteryConfig = []; let isDrawing = false; let prizes = []; const tbodyListEl = document.getElementById("_jj_tbodyList") function delay(fn = () => { }, delay = 5000, context = null) { let ticket = null; let runned = false; return { run(. args) { return new Promise((resolve, reject) = > { if (runned === true) { return; } runned = true; ticket = setTimeout(async() = > {try { const res = await fn.apply(context, args); resolve(res); } catch (err) { reject(err) } }, delay) }) }, cancel: () = > { clearTimeout(ticket); }}}function getLotteryConfig() { return fetch("https://api.juejin.cn/growth_api/v1/lottery_config/get") .then(res= > res.json()) } function getSignCount(){ return fetch('https://api.juejin.cn/growth_api/v1/get_counts?aid=2608&uuid=6986922219256989198', {method: 'GET'.credentials: "include" }).then(res= > res.json()) } function getCurPoint(){ return fetch('https://api.juejin.cn/growth_api/v1/get_cur_point?aid=2608&uuid=6986922219256989198', {method: 'GET'.credentials: "include" }).then(res= > res.json()).then(data= >{ document.getElementById("ore_num").innerText = data.data; document.getElementById("draws_num").innerText = Math.floor(data.data/200); document.getElementById("__jj_dialog_title_left").style.visibility='visible'; })}function onSignIn() { return fetch('https://api.juejin.cn/growth_api/v1/check_in', {method: 'POST'.credentials: "include".headers: { 'Content-Type': 'application/json; charset=utf-8; ' }, body: JSON.stringify({aid: '2608'.uuid:'6986922219256989198'}) }).then(res= > res.json()).then(data= >{ if(data.err_no! = =0){ alert(data.err_msg); }else{ onSuccess(); }})}async function onSuccess(){ const count = await getSignCount(); getCurPoint(); console.log(count) alert('Successful check-in, continuous check-in${count.data.cont_count}Day, total check-in${count.data.sum_count}`); } // {"err_no":7003,"err_msg":" lack of point","data":null} function doDraw() { return fetch('https://api.juejin.cn/growth_api/v1/lottery/draw', { method: 'POST'.credentials: "include" }).then(res= > res.json()) } async function onDraw(ev) { if (isDrawing) { return; } isDrawing = true; try { let errNo = 0; do { if(! isDrawing){break; } const res = await doDraw(); getCurPoint(); errNo = res.err_no; if(errNo ! = =0) { alert(res.err_msg); isDrawing = false; break; } // Add rewards addPrize(res.data) / / rendering renderPrizes(); / / pause 16 ms await delay(undefined.16).run(); //isDrawing = false; //break; } while (errNo == 0)}catch (err) { isDrawing = falsealert(err.message); }}function addPrize(data) { let prize = prizes.find(p= > p.lottery_id == data.lottery_id); if(! prize) {return; } prize.counts += 1; } function onStop() { isDrawing = false; } function getTotal(data){ if(data.lottery_id == "6981716980386496552" || data.lottery_name == "66 ore") {return data.counts * 66; } return data.counts; } function renderPrizes() { tbodyListEl.innerHTML = prizes.map(prize= > ` <tr id="_jj_${prize.lottery_id}"> <td class="_jj_price_icon"><img style="height:30px" src="${prize.lottery_image}" /></td> <td>${prize.lottery_name}</td> <td class="_jj_count">${prize.counts}</td> <td class="_jj_total">${getTotal(prize)}</td> </tr> `).join(""); } async function init() { lotteryConfig = (await getLotteryConfig()).data.lottery; prizes = lotteryConfig.map(c= > ({ lottery_id: c.lottery_id, lottery_name: c.lottery_name, lottery_image: c.lottery_image, counts: 0 })); renderPrizes(); document.getElementById("_jj_btn_sign_in").addEventListener("click",onSignIn) document.getElementById("_jj_btn_draw").addEventListener("click", onDraw); document.getElementById("_jj_btn_stop").addEventListener("click", onStop); document.getElementById("_jj_btn_close").addEventListener("click".function () { document.querySelector("#_jj_draw_container").style.display = "none"}); } init(); }) ();Copy the code

Write in the last

If I have seen further than others, it is because I stand on the shoulders of giants and thank the world for its inspiration

Finally, make an advertisement for yourself: all the annoying personal blog sites