[GC] Pet Counter

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

当前为 2024-12-06 提交的版本,查看 最新版本

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

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

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

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

您需要先安装一款用户脚本管理器扩展,例如 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}`);
    //return petClasses;
}

// Example usage
//const petClassCount = countPetClasses();
//alert(`Number of Pets on this lookup: ${petClassCount}`);

    // Create a button that scrolls with the page
const button = document.createElement('button');
button.innerText = 'Count Pet Classes';
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);



})();