Daily NodeSeek Board Opener

Automatically open a page and click a button once a day

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

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

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

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

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

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

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Daily NodeSeek Board Opener
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Automatically open a page and click a button once a day
// @author       nodeseeker
// @match        https://www.nodeseek.com/*
// @grant        none
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    // Define the function that will click the button
    function clickButton() {
        const button = document.querySelector('button.btn[data-v-6ef9e4cd]');
        if (button) {
            button.click();
            // Store the current time as the last click time
            localStorage.setItem('lastClickTime', new Date().getTime());
        }
    }

    // This function will check if the current page is the board page
    function isBoardPage() {
        return window.location.href.includes('/board');
    }

    // Your code here...
    const urlToOpen = 'https://www.nodeseek.com/board';
    const lastClickTime = localStorage.getItem('lastClickTime');
    const currentTime = new Date().getTime();

    // Check if a day has passed
    if (!lastClickTime || currentTime - lastClickTime > 86400000) { // 86400000 ms in a day
        // If a day has passed or it has never been clicked, and we are not already on the board page, open the page
        if (!isBoardPage()) {
            window.open(urlToOpen, '_self');
        }
    }

    // If we are on the board page, wait for it to load, then click the button
    if (isBoardPage()) {
        // Wait for the page to load
        window.addEventListener('load', function() {
            // Wait an additional 2 seconds after the page load
            setTimeout(clickButton, 2000); // 2000 milliseconds = 2 seconds
        });
    }
})();