Neopets - Karla's Tea Time With Tavi Search Helper

Adds easy search ssw and sw buttons to Tea Time With Tavi quest

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Neopets - Karla's Tea Time With Tavi Search Helper
// @namespace    karla@neopointskarla
// @license      GPL3
// @version      0.0.5
// @description  Adds easy search ssw and sw buttons to Tea Time With Tavi quest
// @author       Karla
// @match        *://*.neopets.com/games/teatime*
// @icon         https://github.com/karlaneo/neopets-scripts/blob/main/favicon-32x32.png?raw=true
// @grant        none
// ==/UserScript==

function insertButtons (target, stamp) {
    try {
        const div = document.createElement('div');
        const hasSSW = toggleSSW__2020;
        if (hasSSW) {
            const sswButton = document.createElement('div');
            sswButton.style.width = '20px';
            sswButton.style.height = '20px';
            sswButton.style.cursor = 'pointer';
            sswButton.style.display = 'inline-block';
            sswButton.innerHTML = '<img src="https://images.neopets.com/shopkeepers/super_shopwizard.gif" style="width: 100%; height: 100%;" />';
            sswButton.addEventListener('click', function() {
                console.log(document.querySelector('#ssw__2020').style.display)
                if (document.querySelector('#ssw__2020').style.display === '' || document.querySelector('#ssw__2020').style.display === 'none') {
                    toggleSSW__2020();
                }
                document.querySelector('#searchstr').value = stamp;
                document.querySelector('#ssw-criteria').selectedIndex = 0;
                document.querySelector('#price-limited').checked = false;
                document.querySelector('#ssw-button-search').click();
            });
            div.appendChild(sswButton);
        }
        const swButton = document.createElement('a');
        swButton.style.width = '20px';
        swButton.style.height = '20px';
        swButton.style.display = 'inline-block';
        swButton.innerHTML = '<img src="https://images.neopets.com/shopkeepers/shopwizard.gif" style="width: 100%; height: 100%;" />';
        swButton.href = `https://www.neopets.com/shops/wizard.phtml?string=${stamp}`;
        swButton.target = '_blank';
        div.appendChild(swButton);
        target.appendChild(div);
    } catch (e) {
        console.log(e);
    }
}

(function() {
    'use strict';

    // Your code here...
    [...document.querySelectorAll('.ttwt-item')].forEach(n => {
        insertButtons(n, n.querySelector('span').textContent);
    })
})();