您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
打开掘金页面后, 自动签到, 每天最多签到一次.签到完之后自动跳抽奖页面,每天最多免费抽一次. 基于iframe实现, 不用担心接口被禁. 只支持 Chrome80+ 浏览器.
当前为
// ==UserScript== // @name [掘金]自动签到&自动抽奖 // @namespace http://tampermonkey.net/ // @version 1.0.9 // @author mgtx // @description 打开掘金页面后, 自动签到, 每天最多签到一次.签到完之后自动跳抽奖页面,每天最多免费抽一次. 基于iframe实现, 不用担心接口被禁. 只支持 Chrome80+ 浏览器. // @license MIT // @icon https://lf3-cdn-tos.bytescm.com/obj/static/xitu_juejin_web//static/favicons/favicon-32x32.png // @match https://juejin.cn/* // @grant none // @run-at document-idle // @noframes // ==/UserScript== (function () { "use strict"; const NAMESPACE = "juejin-auto-check"; const LOCAL_STORAGE_KEY = "tampermonkey-" + NAMESPACE; const LUCKY_PAGE_PATH = 'https://juejin.cn/user/center/lottery?from=lucky_lottery_menu_bar' function getDate () { const date = new Date(); const year = date.getFullYear(); const month = String(date.getMonth() + 1).padStart(2, "0"); const day = String(date.getDate()).padStart(2, "0"); return `${year}-${month}-${day}`; } function createIframe (id) { const iframe = document.createElement("iframe"); iframe.id = id; iframe.style.position = "fixed"; iframe.style.top = "120px"; iframe.style.right = "24px"; iframe.style.width = "375px"; iframe.style.height = "850px"; iframe.style.zIndex = "1000"; iframe.src = "https://juejin.cn/user/center/signin"; return iframe; } function removeIframe (id) { const ele = document.getElementById(id); if (ele) { document.body.removeChild(ele); } } function signIn () { iframeFactory() .then((res) => { const { contentDocument, id } = res || {} const btn = contentDocument.querySelector(".signin.btn"); if (btn) { btn.click(); lucky(contentDocument) } const timer = setTimeout(() => { clear({ id, timer }) updateBtn() }, 1e3); }) } function lucky (contentDocument) { contentDocument.location.href = LUCKY_PAGE_PATH setTimeout(() => { const btn = document.getElementById("turntable-item-0"); if (btn) { btn.click(); } }, 0) } function updateBtn () { const btn = document.getElementById("turntable-item-0"); if (btn) { btn.innerHTML = '' const lotteryText = document.createElement('div') lotteryText.classList.add('lottery-text') lotteryText.textContent = '单抽' btn.appendChild(lotteryText); const btnDataVAttr = (getCustomDataAttributes(btn) || [])[0] const iconNumBox = document.createElement('div') iconNumBox.classList.add('icon-num-box') iconNumBox.setAttribute(btnDataVAttr) btn.appendChild(iconNumBox); const svg = createLotteryIconSvg() svg.setAttribute(btnDataVAttr) iconNumBox.appendChild(svg) const text = document.createElement('div') text.classList.add('text') text.setAttribute(btnDataVAttr) text.textContent = '200' iconNumBox.appendChild(text) } } function getCustomDataAttributes (element) { const prefix = 'data-v-'; const attributes = element.attributes; const customAttributes = []; for (let i = 0; i < attributes.length; i++) { const attr = attributes[i]; if (attr.name.startsWith(prefix)) { customAttributes.push(attr.value); } } return customAttributes; } function createLotteryIconSvg () { const svgNS = 'http://www.w3.org/2000/svg'; const svg = document.createElementNS(svgNS, 'svg'); svg.setAttribute('width', '28'); svg.setAttribute('height', '28'); svg.setAttribute('viewBox', '0 0 28 28'); svg.setAttribute('fill', 'none'); svg.setAttribute('class', 'lottery-icon'); const g = document.createElementNS(svgNS, 'g'); g.setAttribute('filter', 'url(#filter0_d_7401_115365)'); const paths = [ 'M15.5001 7.63319L10.7001 8.30519L8.30008 13.3452L8.96008 15.0557L10.4001 16.3692L11.9001 17.0412L14.3001 18.7212L18.5001 20.4012L21.6878 17.7913C21.839 17.6676 21.9486 17.5004 22.0018 17.3124L23.4114 12.3317C23.5333 11.9011 23.5001 11.4413 23.3177 11.0327L20.9001 5.61719L15.5001 7.63319Z' ]; paths.forEach(pathData => { const path = document.createElementNS(svgNS, 'path'); path.setAttribute('d', pathData); path.setAttribute('fill', '#FFCF8B'); g.appendChild(path); }); const defs = document.createElementNS(svgNS, 'defs'); svg.appendChild(g); svg.appendChild(defs); return svg } function clear ({ id, timer } = {}) { clearTimeout(timer); removeIframe(id); } function iframeFactory () { const id = `iframe-${Math.ceil(Math.random() * 100)}`; const iframe = createIframe(id); document.body.prepend(iframe); return new Promise((resolve) => { iframe.onload = () => { const dialog = document.getElementById(id); if (dialog) { resolve(dialog) } } }) } function main () { const latestDay = localStorage.getItem(LOCAL_STORAGE_KEY); const today = getDate(); if (!latestDay || latestDay !== today) { try { signIn(); localStorage.setItem(LOCAL_STORAGE_KEY, today); } catch (error) { localStorage.removeItem(LOCAL_STORAGE_KEY); } } } main(); })();