Greasy Fork

MH King's Crowns+

Platinum Corwns, Locked Favorites, and More!

目前为 2019-04-04 提交的版本。查看 最新版本

// ==UserScript==
// @name         MH King's Crowns+
// @author       Ben Loll - Warden Slayer#2302
// @namespace    https://greasyfork.org/en/users/227259-wardenslayer
// @version      1.0
// @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"})
};
//
$(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();
       }
   }
});
//
$(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";
       } else {
         // Put the checked value into storage
         localStorage.setItem('ShowAllCrowns', "N");
         showAllCrowns.checked = "";
       }
   }
});
//
function lockFavorites(){
  var allMice = $(".favoriteCrownToggle.crownAction");
  //var cloneMice = allMice.clone(true)
  allMice.off("click");
}
function unlockFavorites(){
  var allMice = $(".favoriteCrownToggle.crownAction");
  allMice.on("click");
}