Nuggets raffle!!

Saved so long nuggets of gold ore, not a really sorry myself, I’m sorry nuggets, I’m sorry workers, see some friends write code, there are bugs ah, simply their own to a draw at the end of a summary form to facilitate brothers screenshots to boiling point yo.

(async() = > {const res = await fetch('https://api.juejin.cn/growth_api/v1/get_cur_point', {
    headers: {
      cookie: document.cookie
    },
    method: 'GET'.credentials: 'include'
  }).then((res) = > res.json());

  let score = res.data; // The current score
  if (score < 200) return console.warn('Not enough to think about what? ');

  const award = {};
  const draw = async() = > {if (score < 200) {
      console.log('The Soha is over! ');
      console.table(award);
      alert(JSON.stringify(award, null.2));
      return;
    }

    const result = await fetch('https://api.juejin.cn/growth_api/v1/lottery/draw', {
      headers: {
        cookie: document.cookie
      },
      method: 'POST'.credentials: 'include'
    }).then((res) = > res.json());

    if (result.data.lottery_type === 1) score += 66;

    if (award[result.data.lottery_name]) award[result.data.lottery_name]++;
    else award[result.data.lottery_name] = 1;

    console.log(` won:${result.data.lottery_name}`);
    draw();
  };

  console.log('Begin the soha! '); draw(); }) ();Copy the code

Copy the code above to your browser console and press Enter to start!!

Grease monkey script

After the workers remind, update, add an oil monkey script, there is a need to directly copy to the oil monkey, in this thanks to the west gate piaopiao to provide advice

Update to add 5 – to – 10 – to – pull function.

// ==UserScript==
// @name jackpot lucky draw
// @namespace http://tampermonkey.net/
/ / @ version 1.0.0
// @description one-click lottery
/ / @ author no fairy
// @match https://juejin.cn/*
// @icon https://lf3-cdn-tos.bytescm.com/obj/static/xitu_juejin_web//static/favicons/favicon-32x32.png
// @grant none
// ==/UserScript==

(function () {
  'use strict';

  // lottery logic
  let loading = false;
  const draw = async (times) => {
    if (loading) return;
    const res = await fetch('https://api.juejin.cn/growth_api/v1/get_cur_point', {
      headers: {
        cookie: document.cookie
      },
      method: 'GET'.credentials: 'include'
    }).then((res) = > res.json());

    let score = res.data; // The current score
    if (score < 200 * (times || 1)) return console.warn('Not enough to think about what? ');

    let i = 0;
    const award = {};
    const draw = async() = > {if (score < 200 || i === times) {
        loading = false;
        i = 0;
        console.log(`${times ? times + 'even smoking' : 'show hand'}The end! `);
        console.table(award);
        alert(JSON.stringify(award, null.2));
        return;
      }

      const result = await fetch('https://api.juejin.cn/growth_api/v1/lottery/draw', {
        headers: {
          cookie: document.cookie
        },
        method: 'POST'.credentials: 'include'
      }).then((res) = > res.json());

      i++;

      if (result.data.lottery_type === 1) score += 66;

      if (award[result.data.lottery_name]) award[result.data.lottery_name]++;
      else award[result.data.lottery_name] = 1;

      console.log(` to draw:${result.data.lottery_name}`);
      draw();
    };

    console.log(` began${times ? times + 'even smoking' : 'show hand'}! `);
    loading = true;
    draw();
  };

  / / insert the DOM
  const container = document.createElement('div');
  container.id = 'wx_draw_wrap';
  container.innerHTML = ` < div id = "wx_draw_all_in" > show hand draw < / div > < ul id = "wx_draw_list" > < li id = "wx_draw_5" > 5 even smoking < / li > < li id = "wx_draw_10" > 10 even smoking < / li >  `;
  document.body.appendChild(container);

  / / get the DOM
  const all_in_btn = document.getElementById('wx_draw_all_in');
  const draw_5_btn = document.getElementById('wx_draw_5');
  const draw_10_btn = document.getElementById('wx_draw_10');

  // Event binding
  all_in_btn.addEventListener('click', draw);
  draw_5_btn.addEventListener('click'.() = > draw(5));
  draw_10_btn.addEventListener('click'.() = > draw(10));

  // Handle styles
  const style = ` #wx_draw_wrap { box-sizing: border-box; position: fixed; top: 50%; left: 0px; z-index: 999999; margin-top: -20px; } #wx_draw_all_in { box-sizing: border-box; width: 40px; height: 40px; line-height: 16px; font-size: 12px; padding: 4px; background-color: rgb(232, 243, 255); border: 1px solid rgb(232, 243, 255); color: rgb(30, 128, 255); text-align: center; overflow: hidden; cursor: pointer; } #wx_draw_wrap:hover { width: 128px; } #wx_draw_wrap:hover #wx_draw_list { display: block; } #wx_draw_list { display: none; width: 80px; position: absolute; right: 0; top: 0; } #wx_draw_list li { box-sizing: border-box; cursor: pointer; margin-bottom: 4px; background-color: rgb(232, 243, 255); border: 1px solid rgb(232, 243, 255); color: rgb(30, 128, 255); font-size: 12px; height: 18px; line-height: 18px; text-align: center; } `;

  const styleEl = document.createElement('style');
  styleEl.textContent = style;
  document.head.appendChild(styleEl); }) ();Copy the code

The latest script uses petite-Vue for visualization, code address: github.com/hccluck/tam… Latest script preview: