This article has participated in the “Digitalstar Project” and won a creative gift package to challenge the creative incentive money.

The comments section of this article has been added to the lucky draw luxury package, see the details at the end of the article ~

Complete daily tasks automatically

Access to any resources under the gold digging site will trigger daily task detection, if detected not done, then the background will automatically request the relevant connection to complete these daily tasks [signin + white piao lottery], with a pop-up prompt, and then automatically shut down

If you have finished your day, print a message on the console

Lottery function integration

In the top column of the page, added a magic button, euro emperor appraiser

After clicking, the pop-up window will display the lucky draw results one by one. The effect is as follows:

After the drawing is completed, the drawing summary result will be displayed and output to the console:

use

I assumed that everyone had already installed the oil Monkey plugin, just left click the plugin icon -> add a new script, and then copy and paste the entire code behind it

The source code

Note: I am still researching how to automatically obtain the AID and UUID, so the script is directly written, if there is a problem with the use of console check your request with the AID and UUID, and then replace the first line of the userInfo variable

// ==UserScript==
// @name Juejin Activities Enhancer
// @name: zh-cn
/ / @ version 0.1
// @description:zh-CN
// @match https://juejin.cn/**
// @run-at document-end
// ==/UserScript==
{
  let userInfo = 'aid=2608&uuid=7016487434494658063';
  let httpConfig = {
    "headers": {
      "accept": "* / *"."accept-language": "zh-CN,zh; Q = 0.9"."content-type": "application/json"."sec-ch-ua": "\"Chromium\"; v=\"94\", \"Google Chrome\"; v=\"94\", \"; Not A Brand\"; v=\"99\""."sec-ch-ua-mobile": "? 0"."sec-ch-ua-platform": "\"Windows\""."sec-fetch-dest": "empty"."sec-fetch-mode": "cors"."sec-fetch-site": "same-site"
    },
    "referrer": "https://juejin.cn/"."referrerPolicy": "strict-origin-when-cross-origin"."body": "{}"."method": "POST"."mode": "cors"."credentials": "include"
  };
  let run = (function() {
    let lastUrl;
    let clickTime;
    return {
      once: () = > {
        clearTimeout(clickTime);
        clickTime = setTimeout(() = > {
          if(lastUrl ! = unsafeWindow.location.href) { lastUrl = unsafeWindow.location.href;console.log('reload by setInterval', lastUrl);
            business(unsafeWindow.$)
          }
        }, 500)},setLastUrl: (url) = >{ lastUrl = url; }}}) ();let htmlInDoc = (function() {
    return {
      appendDialog: () = > {
        let html =
          `
      
`
; $('body').append(html); }, appendRecord: (msg) = > { let html = `<div style="padding: 5px; font-size: 16px;" >${msg}</div>`; $('#lotteryResultDialog').prepend(html); }, closeDialog: (time = 1200) = > { setTimeout(() = > $('#lotteryResultDialog').remove(), time) }, empty: () = >{$('#lotteryResultDialog').empty(); }}}) ();// Used to load jq function loadScript(src, callback) { var script = document.createElement('script'), head = document.getElementsByTagName('head') [0]; script.type = 'text/javascript'; script.charset = 'UTF-8'; script.src = src; if (script.addEventListener) { script.addEventListener('load'.function() { callback(); }, false); } else if (script.attachEvent) { script.attachEvent('onreadystatechange'.function() { var target = window.event.srcElement; if (target.readyState == 'loaded') { callback(); }}); } head.appendChild(script); }// Delay the call to make sure the HTML is rendered properly setTimeout(() = > { if (typeof jQuery == 'undefined') { loadScript('https://code.jquery.com/jquery-3.1.1.min.js'.() = > {}); } let loadTime; loadTime = setInterval(() = > { // Polling checks the JQ load if (typeofjQuery ! ='undefined') { clearInterval(loadTime); business(unsafeWindow.$) // Delay detection of page URL changes when a page is clicked run.setLastUrl(unsafeWindow.location.href); $(document).on('click'.The '*'.function() { run.once(); })}},1000); }, 500) function business($) { async function dayTask() { console.log('Calling a daily function') let msgs = []; let freeLottery = true; / / sign in await fetch( `https://api.juejin.cn/growth_api/v1/check_in?${userInfo}&_signature=_02B4Z6wo00101q966EAAAIDCL3gSAGCq5SKvfuzAAMrJs3JkiZSLejXKJy5lR-3Rot9hYdZVnmHKrdQPh0MmwDCQsjT9tEIN0G3uIK8RsU7 pcEznZ9.oqqfseed8PMV.rul6lxG-dkqFtwsq61`, httpConfig) .then(function(response) { return response.json(); }).then(data= > { if (data.err_msg == 'success') { msgs.push('Check in successful! '); } else { freeLottery = false; msgs.push(data.err_msg); } console.log(data); }); if(! freeLottery)return false; // Quit without a free draw await fetch(`https://api.juejin.cn/growth_api/v1/lottery/draw?${userInfo}`, httpConfig) .then(function(response) { return response.json(); }).then(data= > { if (data.err_msg == 'success') { msgs.push('Win a prize${data.data.lottery_name}`); } console.log(data); }); htmlInDoc.appendDialog(); htmlInDoc.appendRecord(msgs.join('<br>')); htmlInDoc.closeDialog(1200); } unsafeWindow.choujiang = async function choujiang() { console.log('Call the lottery function') let obj = {}; let flag = true; htmlInDoc.appendDialog(); for (; flag;) { await fetch(`https://api.juejin.cn/growth_api/v1/lottery/draw?${userInfo}`, httpConfig) .then(function(response) { return response.json(); }).then(data= > { if (data.err_msg == 'success') { let name = data.data.lottery_name; console.log(name); htmlInDoc.appendRecord(name) obj[name] = obj[name] || 0; obj[name] = obj[name] + 1; } else { flag = false; }})console.log(obj) } let keys = Object.keys(obj); htmlInDoc.empty(); htmlInDoc.appendRecord(keys.length > 0 ? keys.map(k= > k + ':' + obj[k]).join('<br>') : 'Not enough lucky draws! ') htmlInDoc.closeDialog(1200); return false; } let $menu = $('.nav-list>.main-nav-list>ul'); // $menu.find('li:last').remove(); $menu.append(` '); // Delay execution setTimeout(() = > { // Detect whether automatic check-in and free lottery are required let val = unsafeWindow.localStorage.juejinDayTask; let date = new Date(a);let currDate = [date.getFullYear(), date.getMonth() + 1, date.getDate()].join(The '-'); if (val == null|| val ! = currDate) { dayTask(); unsafeWindow.localStorage.juejinDayTask = currDate; }else { console.log('Signed in + lucky draw')}},2000)}}Copy the code

Feel nice XDM to the comment section of the message support ya ~

Please feel free to discuss in the comments section. The nuggets will draw 100 nuggets in the comments section after the diggnation project. See the event article for details