Created
July 7, 2025 02:55
-
-
Save eai04191/2fb1c5ff09de408636f66f566f8d0cd7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name bm2dxinf rel/trial 別リロード後再クリック | |
// @namespace http://tampermonkey.net/ | |
// @version 1.2 | |
// @description bm2dxinf://login?...&rel= または &trial= を押したらリロードして同じ種別を再クリック | |
// @match https://p.eagate.573.jp/game/infinitas/2/api/login/login.html | |
// @grant none | |
// ==/UserScript== | |
(function () { | |
'use strict'; | |
const STORAGE_KEY = 'bm2dxinf_click_target'; | |
const getTargetType = href => { | |
if (/^bm2dxinf:\/\/login\?.+&rel=/.test(href)) return 'rel'; | |
if (/^bm2dxinf:\/\/login\?.+&trial=/.test(href)) return 'trial'; | |
return null; | |
}; | |
// 1. リロード後に保存された種別を探してクリック | |
const saved = sessionStorage.getItem(STORAGE_KEY); | |
if (saved) { | |
sessionStorage.removeItem(STORAGE_KEY); | |
const target = [...document.querySelectorAll('a')].find(a => { | |
const type = getTargetType(a.href); | |
return type === saved; | |
}); | |
if (target) { | |
console.log(`"${saved}" のリンクを再クリックします:`, target.href); | |
target.click(); | |
} else { | |
console.warn(`"${saved}" に該当するリンクが見つかりませんでした`); | |
} | |
} | |
// 2. ユーザークリック時に種類を記録してリロード | |
document.addEventListener('click', function (e) { | |
const anchor = e.target.closest('a'); | |
if (anchor) { | |
const type = getTargetType(anchor.href); | |
if (type) { | |
e.preventDefault(); | |
sessionStorage.setItem(STORAGE_KEY, type); | |
console.log(`"${type}" リンクを記録してリロードします`); | |
location.reload(); | |
} | |
} | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment