Greasy Fork

Greasy Fork is available in English.

MH King's Crowns+

Platinum Corwns, Locked Favorites, and More!

当前为 2019-04-08 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         MH King's Crowns+
// @author       Ben Loll - Warden Slayer#2302
// @namespace    http://greasyfork.icu/en/users/227259-wardenslayer
// @version      1.1
// @description  Platinum Corwns, Locked Favorites, and More!
// @include      https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js
// @include      http://www.mousehuntgame.com/*
// @include      https://www.mousehuntgame.com/*
// ==/UserScript==
//===================================================================================
$(document).ready(function() {
   var observer = new MutationObserver(callback);
   var observerOptions = {
        childList: true,
        attributes: false,
        subtree: false,
      };
   observer.observe($("#tabbarContent_page_2").get(0), observerOptions)
});
//
function callback(mutationList, observer) {
     mutationList.forEach((mutation) => {
       switch(mutation.type) {
         case 'childList':
            console.log("Mutation")
            buildToolbar()
            break;
          }
     })
};
//
function buildToolbar(){
    //If we already have an hideLe Section, do not make another
    if ($('.toolBar').length > 0)
        return;
    var toolBar = document.createElement("div");
    toolBar.classList.add('toolBar')
    //Lock Favs Cb
    var lockFavs = document.createElement('input');
    lockFavs.type = "checkbox";
    lockFavs.name = "lockFavs";
    lockFavs.value = "";
    lockFavs.id = "lockFavs";
    if (localStorage.getItem('LockFavs') == "Y") {
      lockFavs.checked = "Yes";
    } else {
      lockFavs.checked = "";
    }
    var lockFavsLabel = document.createElement('label')
    lockFavsLabel.htmlFor = "lockFavsLabel";
    lockFavsLabel.appendChild(document.createTextNode('Lock Favorites'));
    toolBar.appendChild(lockFavs);
    toolBar.appendChild(lockFavsLabel);
    //All Crowns Cb
    var showAllCrowns = document.createElement('input');
    showAllCrowns.type = "checkbox";
    showAllCrowns.name = "showAllCrowns";
    showAllCrowns.value = "";
    showAllCrowns.id = "showAllCrowns";
    showAllCrowns.checked = "";
     if (localStorage.getItem('ShowAllCrowns') == "Y") {
      showAllCrowns.checked = "Yes";
    } else {
      showAllCrowns.checked = "";
    }
    var showAllCrownsLabel = document.createElement('label')
    showAllCrownsLabel.htmlFor = "showAllCrownsLabel";
    showAllCrownsLabel.appendChild(document.createTextNode('Show Community Crowns'));
    toolBar.appendChild(showAllCrowns);
    toolBar.appendChild(showAllCrownsLabel);
    //last
    var crownBreak = $(".crownbreak").get(0);
    //var displayBox = $(".crownheader.crownheadertop");
    crownBreak.append(toolBar)
    $(".toolBar").css({"float":"right"})
};
//================================= Lock Favs ====================================
//
$(document).on('change', '#lockFavs', function() {
   if ((window.location.href).includes("profile.php")&&$("#tabbarContent_page_2").hasClass("active")) {
      //
       //check to see if the cb was JUST checked
      if(this.checked) {
         // Put the checked value into storage
         localStorage.setItem('LockFavs', "Y");
         lockFavs.checked = "Yes";
         lockFavorites();
       } else {
         // Put the checked value into storage
         localStorage.setItem('LockFavs', "N");
         lockFavs.checked = "";
         unlockFavorites();
       }
   }
});
//
function lockFavorites(){
  var allMice = $(".favoriteCrownToggle.crownAction");
  //var cloneMice = allMice.clone(true)
  allMice.off("click");
}
function unlockFavorites(){
  var allMice = $(".favoriteCrownToggle.crownAction");
  allMice.on("click");
}
//================================== Crowns =====================================
//
$(document).on('change', '#showAllCrowns', function() {
   if ((window.location.href).includes("profile.php")&&$("#tabbarContent_page_2").hasClass("active")) {
      //
       //check to see if the cb was JUST checked
      if(this.checked) {
         // Put the checked value into storage
         localStorage.setItem('ShowAllCrowns', "Y");
         showAllCrowns.checked = "Yes";
         buildCrownHeaders();
         sortCrowns();
       } else {
         // Put the checked value into storage
         localStorage.setItem('ShowAllCrowns', "N");
         showAllCrowns.checked = "";
       }
   }
});
//
function buildCrownHeaders () {
        var crownBreak = $(".crownbreak").first();
        var spacer1 = $(".crownbreak").last().clone();
        var spacer2 = spacer1.clone();
        var spacer3 = spacer1.clone();
        var platinumHeader = $("<div class='crownheader crownheaderplatinum'>Platinum Crowns <span class='crownquantity'>(1)</span> <div class='crownnote'>Earned at 1000 catches</div></div>")
        var diamondHeader = $("<div class='crownheader crownheaderdiamond'>Diamond Crowns <span class='crownquantity'>(0)</span> <div class='crownnote'>Earned at 5000 catches</div></div>")
        var masterHeader = $("<div class='crownheader crownheadermaster'>Master Crowns <span class='crownquantity'>(0)</span> <div class='crownnote'>Earned at 10000 catches</div></div>")
        //Add Larry Later <10
        //
        //Plat
        var allMice = $(".favoriteCrownToggle.crownAction");
        var allGold = allMice.find(".numcatches.gold");
        if (allGold.filter(function(index){
            if($(this).text() >= 600){
            return true;
            } else {
            return false;
            }
        }).length > 0) {
        platinumHeader.insertAfter(crownBreak);
        spacer3.insertAfter(platinumHeader);
        }
        //Diamond
        if (allGold.filter(function(index){
            if($(this).text() >= 800){
            return true;
            } else {
            return false;
            }
        }).length > 0) {
        diamondHeader.insertAfter(crownBreak);
        spacer1.insertAfter(diamondHeader);
        }
        //Master
        if (allGold.filter(function(index){
            if($(this).text() >= 900){
            return true;
            } else {
            return false;
            }
        }).length > 0) {
        masterHeader.insertAfter(crownBreak);
        spacer2.insertAfter(masterHeader);
        }
        
}
function sortCrowns() {
    //Plat
    if ($(".crownheader.crownheaderplatinum").length > 0) {
        sortPlatinum()
    }
    //Diamond
    if ($(".crownheader.crownheaderdiamond").length > 0) {
        sortDiamond()
    }
    //Master
    if ($(".crownheader.crownheadermaster").length > 0) {
        sortMaster()
    }
    //================
    }
function sortPlatinum() {
    var allMice = $(".favoriteCrownToggle.crownAction");
    var allGold = allMice.find(".numcatches.gold");

    var allPlatinum = allGold.filter(function(index) {
        if ($(this).text() >= 600 && $(this).parent().parent().parent().attr("data-action") === "addFavoriteCrown") {
            return true;
        } else {
            return false;
        }
    }).parent().parent().parent();
    var platinumHeader = $(".crownheader.crownheaderplatinum")
    allPlatinum.insertAfter(platinumHeader);
    allPlatinum.find(".numcatches.gold").removeClass("numcatches gold").addClass("numcatches plat");
    platinumHeader.find(".crownquantity").text("("+allPlatinum.length+")")
    //var img = <a href="https://imgbb.com/"><img src="https://i.ibb.co/BfGw6Rj/crown-platinum.png" alt="crown-platinum" border="0" /></a>
    platinumHeader.css("background","url('https://i.ibb.co/BfGw6Rj/crown-platinum.png')  no-repeat left top");
    $(".numcatches.plat").css("background","url('https://i.ibb.co/BfGw6Rj/crown-platinum.png')  no-repeat right top");
}
function sortDiamond() {
    var allMice = $(".favoriteCrownToggle.crownAction");
    var allPlat = allMice.find(".numcatches.plat");
    var allDiamond = allPlat.filter(function(index) {
        if ($(this).text() >= 800 && $(this).parent().parent().parent().attr("data-action") === "addFavoriteCrown") {
            return true;
        } else {
            return false;
        }
    }).parent().parent().parent();

    var diamondHeader = $(".crownheader.crownheaderdiamond")
    allDiamond.insertAfter(diamondHeader);
    allDiamond.find(".numcatches.plat").removeClass("numcatches plat").addClass("numcatches diamond");
    diamondHeader.find(".crownquantity").text("("+allDiamond.length+")")
    //var img = <a href="https://imgbb.com/"><img src="https://i.ibb.co/BfGw6Rj/crown-platinum.png" alt="crown-platinum" border="0" /></a>
    diamondHeader.css("background","url('https://i.ibb.co/BfGw6Rj/crown-platinum.png')  no-repeat left top");
    $(".numcatches.diamond").css("background","url('https://i.ibb.co/BfGw6Rj/crown-platinum.png')  no-repeat right top");
}
function sortMaster() {
     var allMice = $(".favoriteCrownToggle.crownAction");
    var allDiamond = allMice.find(".numcatches.diamond");
    var allMaster = allDiamond.filter(function(index) {
        if ($(this).text() >= 900 && $(this).parent().parent().parent().attr("data-action") === "addFavoriteCrown") {
            return true;
        } else {
            return false;
        }
    }).parent().parent().parent();

    var masterHeader = $(".crownheader.crownheadermaster")
    allMaster.insertAfter(masterHeader);
    allMaster.find(".numcatches.plat").removeClass("numcatches plat").addClass("numcatches diamond");
    masterHeader.find(".crownquantity").text("("+allMaster.length+")")
    //var img = <a href="https://imgbb.com/"><img src="https://i.ibb.co/BfGw6Rj/crown-platinum.png" alt="crown-platinum" border="0" /></a>
    masterHeader.css("background","url('https://i.ibb.co/BfGw6Rj/crown-platinum.png')  no-repeat left top");
    $(".numcatches.diamond").css("background","url('https://i.ibb.co/BfGw6Rj/crown-platinum.png')  no-repeat right top");
}

//TO DO
//Toggle crowns off
//Handle favs
//Handle someone else's profile
//MHCC /+90% crowned ranks?
//Fix lock code