Neopets - Pet Lookup / Quick Ref Post-Flash Fix

Replaces that annoying end-of-Flash-support tombstone with the pet image

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name           Neopets - Pet Lookup / Quick Ref  Post-Flash Fix
// @version        0.1
// @namespace
// @include        *://www.neopets.com/quickref.phtml
// @include        *://www.neopets.com/petlookup*
// @description    Replaces that annoying end-of-Flash-support tombstone with the pet image
// @copyright    Lendri Mujina
// @grant        none
// @namespace https://greasyfork.org/users/394566
// ==/UserScript==

//Known issues:
//  On Quick Ref, the script currently only works for the current active pet's module.

(function () {
  'use strict';
    var petAnchor;
    var petName;
    var imgpart = ["<img src=\"http://pets.neopets.com/cpn/","/1/7.png\" style=\"width:100%\;\">"];
    var imgURL;
    var currentURL=window.location.href;

    if(currentURL.indexOf("petlookup") == -1){
        petName = $(".contentModuleHeader")[0].firstChild.innerHTML;
        $(".flashRIP-content__2020").remove();
        petAnchor = $(".flashRIP__2020")[0];
        imgURL = imgpart[0] + petName + imgpart[1];
        petAnchor.innerHTML = imgURL;
    }
    else{
        $(".flashRIP__2020").remove();
         petAnchor = $(".medText")[4];
        var nameLocation = $('[style="font-weight: bold; font-size: 18px;"]')[0].textContent;
        var petThe = nameLocation.lastIndexOf(" the ");//There's a few very rare pets out there that may have the substring in their names; this accounts for that.
        petName = nameLocation.substr(0,petThe);
        console.log(petName);
        imgURL = imgpart[0] + petName + imgpart[1];
        var existingCode = petAnchor.innerHTML;
        petAnchor.innerHTML = imgURL + "<br><p>" + existingCode + "</p>";
        console.log(imgURL);
        console.log(existingCode);
    };

}
 )();