Neopets: skip NF-only auctions

Ignores Neofriend-only auctions by default

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Neopets: skip NF-only auctions
// @author       Tombaugh Regio
// @version      1.2
// @description  Ignores Neofriend-only auctions by default
// @namespace    https://greasyfork.org/users/780470
// @include      *://www.neopets.com/auctions.phtml*
// @include      *://www.neopets.com/genie.phtml
// @license      MIT
// @grant        none
// ==/UserScript==

if (/genie/.test(window.location.href)) document.querySelector('input[name="exclude_nf_only"]').checked = true
else {
  const NFonly = [...document.querySelectorAll('.content center tr > td:nth-of-type(4)')].slice(1).filter(a => /\[NF\]/.test(a.textContent))
  const NFelement = document.querySelector('.content > center > p:first-of-type')
  const buttonParagraph =  document.createElement('p')
  const button = document.createElement('button')
  
  NFonly.forEach(entry => entry.parentNode.style.display = 'none')
  button.textContent = 'Include [NF]-only auctions'
  
  button.onclick = (e) => {
    e.preventDefault()
    const isFiltered = /Include/.test(button.textContent)
    
    NFonly.forEach(entry => entry.parentNode.style.display = isFiltered ? 'table-row' : 'none')
    button.textContent = isFiltered ? 'Exclude [NF]-only auctions' : 'Include [NF]-only auctions'
  }
  
  buttonParagraph.appendChild(button)
  NFelement.replaceWith(buttonParagraph)  
}