github一键三连

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

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 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);
})();