[GC] Pet Counter

Shows a button on every userlookup that will count the number of pets with an alert

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         [GC] Pet Counter
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description Shows a button on every userlookup that will count the number of pets with an alert
// @author       Masterofdarkness
// @match        https://www.grundos.cafe/userlookup/?user=*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=grundos.cafe
// @grant        none
// @license     MIT
// @downloadURL
// @updateURL
// ==/UserScript==

(function() {
    'use strict';

function countPetClasses() {
    const userPetList = document.getElementById('userPetList');
    if (!userPetList) {
        return 0; // Return 0 if the element with id 'userPetList' does not exist
    }

    const petClasses = Array.from(userPetList.getElementsByClassName('ul__pet')).length;
    alert(`Number of pets on this lookup: ${petClasses}`);
}

// Create a button that scrolls with the page
const button = document.createElement('button');
button.innerText = 'Count # of Pets';
button.style.position = 'fixed';
button.style.bottom = '20px';
button.style.right = '20px';
button.style.padding = '10px';
button.style.backgroundColor = '#4CAF50';
button.style.color = 'white';
button.style.border = 'none';
button.style.borderRadius = '5px';
button.style.cursor = 'pointer';
button.onclick = countPetClasses;

document.body.appendChild(button);



})();