rpg.kr 편의기능 애드온

게임 플레이에 필요한 편의기능을 구현한 스크립트입니다.

目前为 2021-09-16 提交的版本。查看 最新版本

// ==UserScript==
// @name rpg.kr 편의기능 애드온
// @namespace Script Runner Pro
// @description 게임 플레이에 필요한 편의기능을 구현한 스크립트입니다.
// @match https://rpg.kr/
// @grant none
// @version 0.0.2
// ==/UserScript==
/*jshint esversion: 6 */

(_ => {
  // 게임 메뉴를 선택할 때마다 호출되는 함수입니다.
  const frame = document.getElementById("mainFrame");

  frame.onload = function() {
    const doc = frame.contentDocument;
    const main = doc.getElementById("main");

    const observer = new MutationObserver(function(mutations) {
      mutations.forEach(function(mutation) {
        contentChanged();
      });
    });

    observer.observe(main, {
      childList: true
    });

    const contentChanged = () => {
      // 전투 알리미 값을 읽어서 전투/탐사에 최대치를 자동으로 입력합니다.
      var alimi = doc.getElementById("alimiWkpDisp");

      var rept = doc.getElementById("rept");
      var rInp = doc.getElementById("rInp");

      const alimiObserver = new MutationObserver(function(mutations) {
        mutations.forEach(function(mutation) {
          alimiChanged();
        });
      });

      if(alimi) {
        alimiObserver.observe(alimi, {
          childList: true
        });
        alimiChanged();
      }

      const alimiChanged = () => {
        if(rept) {
          rept.value = alimi.textContent;
        }

        if(rInp) {
          rInp.value = parseInt(parseInt(alimi.textContent)/20);
        }
      }
    };


  }
})();