掘金自动签到助手
// ==UserScript==
// @name 掘金自动签到助手
// @namespace ningbnii/monkey_juejin
// @version 0.0.17
// @author ningbnii
// @description 这个油猴脚本可以自动为您在掘金网站上进行签到,省去了手动签到的烦恼。只需安装脚本,它将为您自动完成每日签到任务。
// @license GPLv3
// @icon https://www.wxbuluo.com/favicon.ico
// @match https://juejin.cn/*
// @require https://cdnjs.cloudflare.com/ajax/libs/vue/3.3.4/vue.global.prod.js
// @require https://cdnjs.cloudflare.com/ajax/libs/sweetalert2/11.10.6/sweetalert2.all.min.js
// @grant GM_addStyle
// @grant GM_getValue
// @grant GM_info
// @grant GM_registerMenuCommand
// @grant GM_setValue
// @grant GM_xmlhttpRequest
// ==/UserScript==
(e=>{if(typeof GM_addStyle=="function"){GM_addStyle(e);return}const t=document.createElement("style");t.textContent=e,document.head.append(t)})(' .theme-toggle.theme-toggle--reversed .theme-toggle__classic{transform:scaleX(-1)}.theme-toggle{--theme-toggle__classic--duration: .5s}.theme-toggle__classic path{transition-timing-function:cubic-bezier(0,0,.15,1.25);transform-origin:center;transition-duration:calc(var(--theme-toggle__classic--duration) * .8)}.theme-toggle__classic g path{transition-property:opacity,transform;transition-delay:calc(var(--theme-toggle__classic--duration) * .2)}.theme-toggle__classic :first-child path{transition-property:transform,d}.theme-toggle input[type=checkbox]:checked~.theme-toggle__classic g path,.theme-toggle--toggled:not(label).theme-toggle .theme-toggle__classic g path{transform:scale(.5) rotate(45deg);opacity:0;transition-delay:0s}.theme-toggle input[type=checkbox]:checked~.theme-toggle__classic :first-child path,.theme-toggle--toggled:not(label).theme-toggle .theme-toggle__classic :first-child path{d:path("M-12 5h30a1 1 0 0 0 9 13v24h-39Z");transition-delay:calc(var(--theme-toggle__classic--duration) * .2)}@supports not (d: path("")){.theme-toggle input[type=checkbox]:checked~.theme-toggle__classic :first-child path,.theme-toggle--toggled:not(label).theme-toggle .theme-toggle__classic :first-child path{transform:translate3d(-12px,10px,0)}}.theme-toggle{border:none;background:0 0;cursor:pointer}.theme-toggle input[type=checkbox]{display:none}.theme-toggle .theme-toggle-sr{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border-width:0}@media (prefers-reduced-motion: reduce){.theme-toggle:not(.theme-toggle--force-motion) *{transition:none!important}}.theme-toggle{display:flex;justify-content:center}.read-the-docs{color:#888}.read-the-docs p{font-size:16px;text-align:left;line-height:1.8;letter-spacing:1px}.show-info:hover{cursor:pointer;color:#409eff}.swal2-modal{display:flex!important;flex-direction:column!important}.swal2-modal input{margin:20px auto 0;width:80%!important}.avatar-hover{animation:rotate 60s linear infinite}@keyframes rotate{0%{transform:rotate(0)}to{transform:rotate(1000turn)}}.monkey-box[data-v-ef64befa]{box-shadow:2px 2px 4px #000;background:rgba(255,255,255,.8);position:fixed;bottom:0;z-index:1000;display:flex;flex-direction:column;max-width:300px;padding:10px;-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px);border-radius:10px;margin:10px} ');
(function (vue) {
'use strict';
var T=(()=>typeof GM_getValue<"u"?GM_getValue:void 0)(),H=(()=>typeof GM_info<"u"?GM_info:void 0)(),W=(()=>typeof GM_registerMenuCommand<"u"?GM_registerMenuCommand:void 0)(),S=(()=>typeof GM_setValue<"u"?GM_setValue:void 0)(),v=(()=>typeof GM_xmlhttpRequest<"u"?GM_xmlhttpRequest:void 0)();const z={class:"theme-toggle",title:"Toggle theme"},F=vue.createStaticVNode('<span class="theme-toggle-sr">Toggle theme</span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="2em" height="2em" fill="currentColor" stroke-linecap="round" class="theme-toggle__classic" viewBox="0 0 32 32"><clipPath id="theme-toggle__classic__cutout"><path d="M0-5h30a1 1 0 0 0 9 13v24H0Z"></path></clipPath><g clip-path="url(#theme-toggle__classic__cutout)"><circle cx="16" cy="16" r="9.34"></circle><g stroke="currentColor" stroke-width="1.5"><path d="M16 5.5v-4"></path><path d="M16 30.5v-4"></path><path d="M1.5 16h4"></path><path d="M26.5 16h4"></path><path d="m23.4 8.6 2.8-2.8"></path><path d="m5.7 26.3 2.9-2.9"></path><path d="m5.8 5.8 2.8 2.8"></path><path d="m23.4 23.4 2.9 2.9"></path></g></g></svg>',2),J={__name:"HelloWorld",setup(i){let a=vue.ref("");const s=T("theme")||document.body.getAttribute("data-theme");document.body.setAttribute("data-theme",s);function c(){Swal.fire({title:"使用说明",html:`
<div class="read-the-docs">
<p>登录之后,打开任意掘金网页即可,每天会自动签到</p>
</div>
`,showConfirmButton:!0});}const r=new Date().toLocaleDateString();vue.onMounted(()=>{a.value=T("isSignIn"),(!a.value||a.value!==r)&&$(r),l(),s==="dark"&&(document.querySelector(".theme-toggle input").checked=!0);});let h=null;function l(){h=setInterval(function(){if(!u.value)return;document.querySelectorAll(".avatar").forEach(e=>{e.classList.contains("avatar-hover")||e.classList.add("avatar-hover");});},1e3);}setInterval(()=>{r!==a.value&&$(r);},18e5);function y(t,e=30,o=0){return o>=e?t:typeof t=="string"&&(t.indexOf("%3D")!==-1||t.indexOf("%25")!==-1)?y(decodeURIComponent(t),e,o+1):decodeURIComponent(t)}const B=document.cookie.split(";");let _="",m="",w="";B.forEach(t=>{const[e,o]=t.split("=");if(e.includes("__tea_cookie_tokens_")){_=e.split("__tea_cookie_tokens_")[1];const n=y(o);m=JSON.parse(n).user_unique_id;}e.includes("msToken")&&(w=o);});function I(t){const e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";let o="";for(let n=0;n<t;n++)o+=e.charAt(Math.floor(Math.random()*e.length));return o}const b=I(42);let k=0;f();function f(){v({method:"GET",url:`https://api.juejin.cn/growth_api/v1/get_cur_point?aid=${_}&uuid=${m}&spider=0`,headers:{"content-type":"application","user-agent":navigator.userAgent},responseType:"json",onload:function(t){if(t.status===200){const{err_no:e,err_msg:o}=t.response;if(e===0){const{data:n}=t.response;k=n,k>2e3?E():k>200&&V();}else console.log("获取总矿石失败",o);}else console.log("获取总矿石失败","网络错误");}});}function V(){v({method:"POST",url:`https://api.juejin.cn/growth_api/v1/lottery/draw?aid=${_}&uuid=${m}&spider=0&msToken=${w}&a_bogus=${b}`,headers:{"content-type":"application/json","user-agent":navigator.userAgent},responseType:"json",onload:function(t){if(t.status===200){const{err_no:e,err_msg:o}=t.response;if(e===0){const{data:n}=t.response,{lottery_name:d}=n;Swal.fire({title:"抽奖成功",text:`获得奖品:${d}`,icon:"success",timer:1e3}).then(p=>{f();});}else console.log("抽奖失败",o);}else console.log("抽奖失败","网络错误");}});}function E(){v({method:"POST",url:`https://api.juejin.cn/growth_api/v1/lottery/ten_draw?aid=${_}&uuid=${m}&spider=0&msToken=${w}&a_bogus=${b}`,headers:{"content-type":"application/json","user-agent":navigator.userAgent},responseType:"json",onload:function(t){if(t.status===200){const{err_no:e,err_msg:o}=t.response;if(e===0){const{data:n}=t.response,{LotteryBases:d}=n;d.forEach(p=>{lottery_name+=p.lottery_name+" | ";}),lottery_name=lottery_name.slice(0,-2),Swal.fire({title:"抽奖成功",text:`获得奖品:${lottery_name}`,icon:"success",timer:1e3}).then(p=>{f();});}else console.log("抽奖失败",o);}else console.log("抽奖失败","网络错误");}});}function $(t){v({method:"POST",url:"https://api.juejin.cn/growth_api/v1/check_in",headers:{"content-type":"application","user-agent":navigator.userAgent},responseType:"json",onload:function(e){if(e.status===200){const{err_no:o,err_msg:n}=e.response;if(o===0){const{data:d}=e.response,{sum_point:p,incr_point:D}=d;Swal.fire({title:"签到成功",text:`获得矿石:${D},总矿石:${p}`,icon:"success",timer:2e3}).then(Y=>{f();});}else Swal.fire({title:"签到失败",text:n,icon:"error",timer:2e3});}else Swal.fire({title:"签到失败",text:"网络错误",icon:"error",timer:2e3});S("isSignIn",t),a.value=t;}});}let u=vue.ref(!1);function R(){u.value=!u.value;const t=document.querySelectorAll(".avatar");u.value?(t.forEach(e=>{e.classList.add("avatar-hover");}),l()):(clearInterval(h),t.forEach(e=>{e.classList.remove("avatar-hover");}));}function q(){document.body.getAttribute("data-theme")==="light"?(S("theme","dark"),document.body.setAttribute("data-theme","dark")):(S("theme","light"),document.body.setAttribute("data-theme","light"));}return (t,e)=>(vue.openBlock(),vue.createElementBlock(vue.Fragment,null,[vue.createElementVNode("label",z,[vue.createElementVNode("input",{type:"checkbox",onClick:e[0]||(e[0]=o=>q())}),F]),vue.createElementVNode("span",{class:"show-info",onClick:e[1]||(e[1]=o=>c())},vue.toDisplayString(vue.unref(a)?"已签到:":"未签到")+vue.toDisplayString(vue.unref(a)),1),vue.createElementVNode("span",{class:"show-info",onClick:e[2]||(e[2]=o=>R())},"旋转:"+vue.toDisplayString(vue.unref(u)?"off":"on"),1)],64))}};const Z=(i,a)=>{const s=i.__vccOpts||i;for(const[c,r]of a)s[c]=r;return s},K={class:"monkey-box"},A="https://scriptcat.org/zh-CN/script-show-page/1278",Q={__name:"App",setup(i){W("脚本官网",function(){location.href="https://www.wxbuluo.com";}),a();async function a(){const s=H.script.version;try{const r=await(await fetch(A)).text(),h=/<dd class="script-show-version".*?>\s*<span[^>]*>([\d.]+)<\/span>/,l=r.match(h);l&&l[1]&&s!==l[1]&&(await Swal.fire({title:"脚本有更新",html:`
<div >
<p>当前版本:${s}</p>
<p>最新版本:${l[1]}</p>
</div>
`,showConfirmButton:!0,showCancelButton:!0,confirmButtonText:"立即更新",cancelButtonText:"稍后更新"})).isConfirmed&&window.open(A,"_blank");}catch(c){console.error("检查更新时出错:",c);}}return (s,c)=>(vue.openBlock(),vue.createElementBlock("div",K,[vue.createVNode(J)]))}},X=Z(Q,[["__scopeId","data-v-ef64befa"]]);vue.createApp(X).mount((()=>{const i=document.createElement("div");return document.body.append(i),i})());
})(Vue);