Greasy Fork

Greasy Fork is available in English.

掘金快速抽奖

跳过掘金抽奖动画环节

当前为 2021-09-01 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         掘金快速抽奖
// @namespace    web_chaser
// @version      0.2
// @description  跳过掘金抽奖动画环节
// @author       web_chaser
// @match        https://juejin.cn/*
// @icon         data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant        none
// @update       https://gitee.com/web_chaser/nuggets-quick-draw/blob/master/index.js
// ==/UserScript==

(function() {
    'use strict';

    window.onload = createDom;
    function createDom(){
        var dom = document.createElement('div');
        dom.className = 'turntable-item item lottery';
        dom.style.cssText = 'display: flex; align-items: center; justify-content: space-around; flex-direction: column;'
        var button = document.createElement('button');
        button.innerText = '抽奖';
        var input = document.createElement('input');
        input.style.cssText = 'width: 60%;';
        input.placeholder = '抽奖次数';
        dom.appendChild(button);
        dom.appendChild(input);
        var oldDom = document.getElementsByClassName('turntable-item item lottery')[0];
        console.log(oldDom)
        oldDom.parentNode.replaceChild(dom, oldDom);
        button.onclick = function (){
            executeCount(input.value );
        }
    }

    function executeCount(num){
        num = num ? num : 1;
        for(var i = 0; i < num; i++){
            run();
        }
    }

    function run(){
        var ajax = new XMLHttpRequest();
        ajax.open('post','https://api.juejin.cn/growth_api/v1/lottery/draw',true);
        ajax.withCredentials = true;
        ajax.setRequestHeader('content-type','application/json; charset=utf-8');
        ajax.send(JSON.stringify({}));
        ajax.onreadystatechange = function (){
            if(ajax.readyState==4&&ajax.status==200){
                var c = ajax.responseText;
                c = JSON.parse(c);
                var value = c.data.lottery_name;
                console.log('抽奖获得:' + value);
            }
        }
    }
})();