GC Neggsweeper Tracker

Tracks the number of neggs you have received each day. Does not work across multiple devices.

目前為 2023-09-26 提交的版本,檢視 最新版本

// ==UserScript==
// @name         GC Neggsweeper Tracker
// @namespace    https://gf.qytechs.cn/en/users/1175371/
// @version      0.2
// @description  Tracks the number of neggs you have received each day. Does not work across multiple devices.
// @author       sanjix
// @match        https://www.grundos.cafe/games/neggsweeper/
// @icon         https://www.google.com/s2/favicons?sz=64&domain=grundos.cafe
// @grant        none
// ==/UserScript==

var gridHeader = document.querySelector('#neggsweeper_status');
var headers = document.querySelectorAll('.bg-gold')[2]
headers.id = 'trackerHeader';
var values = document.querySelector('.bg-gold:nth-child(3) + div + div + div');
values.id = 'trackerValue';

var counterHeader = document.createElement('div');
counterHeader.className = 'bg-gold';
counterHeader.textContent = 'Neggs Won';

var counterValue = document.createElement('div');
headers.after(counterHeader);
values.after(counterValue);

gridHeader.style.gridTemplateColumns = '30% 20% 30% 20%';

const today = new Date();
const nstDate = today.toLocaleString("en-US", "America/Los_Angeles");
var neggCount = JSON.parse(localStorage.getItem('neggCounter')) || 0;

if (localStorage.getItem('storedDate') === null) {
    localStorage.setItem('storedDate', JSON.stringify(nstDate));
}

function parseDate(dateString) {
    //returns date from Date String
    return dateString.match(/\d+\/(\d+)\/\d+/)[1];
}


//if stored date is not equal to current date, reset counter and date
if (parseDate(nstDate) != parseDate(localStorage.getItem('storedDate'))) {
    neggCount = 0;
    localStorage.setItem('neggCounter', JSON.stringify(neggCount));
} else {
    neggCount = JSON.parse(localStorage.getItem('neggCounter'));
}
counterValue.textContent = neggCount;


if (document.evaluate(
        "count(//main//p[contains(.,'You also win a ')]) > 0",
        document,
        null,
        XPathResult.BOOLEAN_TYPE,
        null
    ).booleanValue) {

    neggCount += 1;
    counterValue.textContent = neggCount;
    localStorage.setItem('neggCounter', JSON.stringify(neggCount));

}

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址