GC Neggsweeper Tracker

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

当前为 2023-09-26 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         GC Neggsweeper Tracker
// @namespace    https://greasyfork.org/en/users/1175371/
// @version      0.3
// @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));

} else if (document.evaluate(
        'count(//p[contains(.,"So far today")])',
        document,
        null,
        XPathResult.BOOLEAN_TYPE,
        null
    ).booleanValue) {
    var neggP = document.createElement('p');
    neggP.textContent = "You have won " + JSON.parse(localStorage.getItem('neggCounter')) + " neggs today."
    document.querySelector('p + p + p').after(neggP);
}