JOL+

Some UI additions to JOL

目前為 2019-02-22 提交的版本,檢視 最新版本

// ==UserScript==
// @name         JOL+
// @namespace    https://github.com/shmup
// @version      1.0.0
// @description  Some UI additions to JOL
// @author       shmug
// @include	 https://test.deckserver.net/jol/*
// @run-at       document-idle
// @grant        GM_addStyle
// ==/UserScript==

/* jshint esversion: 6 */

GM_addStyle("#preview { height: 375px}");
GM_addStyle("#preview img { height: 100%}");

(function(window) {
  "use strict";

  // add the preview
  document.getElementById("loaded").innerHTML += `<div id='preview' />`;
  const preview = document.getElementById("preview");

  const clearPreview = () => {
    preview.innerHTML = "";
  };

  const cleanCard = name => {
    return name.toLowerCase().replace(/\W/g, "");
  };

  const appendCard = name => {
    const img = document.createElement("img");
    img.src = `https://smell.flowers/rubbish/vtes/scans/${name}.jpg`;
    preview.appendChild(img);
  };

  // Select the node that will be observed for mutations
  const playerHand = document.getElementById("playerHand");

  // Callback function to execute when mutations are observed
  const callback = function(mutationsList, observer) {
    let cards;

    for (const mutation of mutationsList) {
      if (mutation.type === "childList") {
        clearPreview();

        // figure out all the cards and draw them!
        cards = document
          .getElementById("playerHand")
          .querySelectorAll(".card-name");

        cards.forEach(card => {
          appendCard(cleanCard(card.innerText));
        });
      }
    }
  };

  // Create an observer instance linked to the callback function
  const observer = new MutationObserver(callback);

  // Start observing the target node for mutations
  observer.observe(playerHand, {
    attributes: true,
    childList: true,
    subtree: true
  });
})(window);

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址