Greasy Fork

Greasy Fork is available in English.

掘金一键点赞

为掘金沸点一键点赞

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         掘金一键点赞
// @namespace    http://tampermonkey.net/
// @version      0.5
// @description  为掘金沸点一键点赞
// @author       You
// @match        https://juejin.cn/user/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=juejin.cn
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';
    let latestOffsetHeight = document.body.offsetHeight;
    let counter = 0;
    const sleep = (t) => new Promise(resolve => setTimeout(resolve, t));
    const clickLike = async () => {
        const btns = document.querySelectorAll('.like:not(.active)');
        if(btns?.length) {
            for await(const node of btns) {
                console.log(node);
                await sleep(300);
                node.click();
            }
        }
        scrollTo(0, document.body.offsetHeight);
        await sleep(1000);
        if(document.body.offsetHeight === latestOffsetHeight) {
            counter++;
        } else {
            counter = 0;
        }
        latestOffsetHeight = document.body.offsetHeight;
        if(counter < 3) await clickLike();
    }
    const handleClick = async () => {
        btn.disabled = true;
        btn.innerText = '点赞中...';
        await clickLike();
        btn.disabled = false;
        btn.innerText = '已完成';
    }
    const btn = document.createElement('button');
    btn.innerText = '一键点赞';
    btn.className = 'btn';
    btn.style = 'position: fixed;left: 0;bottom: 10%;';
    btn.addEventListener('click', handleClick);
    document.body.appendChild(btn);
})();