Neopets - Pet Lookup / Quick Ref Post-Flash Fix

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

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

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

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

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

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

}
 )();