github一键三连

Adds a button for one-click triple action (Watching, Star, and Fork) on GitHub

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         github一键三连
// @namespace    emptycity
// @version      1.0
// @description  Adds a button for one-click triple action (Watching, Star, and Fork) on GitHub
// @author       Isaac Asimov
// @match        https://github.com/*
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    function createButton() {
        // Create a button element
        const button = document.createElement('button');
        button.textContent = '一键三连';
        button.style.position = 'fixed';
        button.style.top = '60px';
        button.style.right = '20px';
        button.style.zIndex = '9999';

        // Append the button to the body
        document.body.appendChild(button);

        // Add click event listener to the button
        button.addEventListener('click', performTripleAction);
    }

    function performTripleAction() {

        // Find the Watching, Star, and Fork buttons on the page
        const watchingButton = document.querySelector('summary[id="repository-details-watch-button"]');
        const forkButton = document.querySelector('a[id="fork-button"]');
        const starButton = document.querySelector('button[aria-label^="Star this repository"]');

        // Click the Star button if it exists
        if (starButton) {
            console.log('star this repository')
            starButton.click();
        }
        // Click the buttons if they exist
        if (watchingButton) {
            console.log('watch this repository');
            watchingButton.click();
        }

        if (forkButton) {
            forkButton.click();
        }
    }

    // Wait for the page to load
    window.addEventListener('load', createButton);
})();