// ==UserScript== // @name Granblue Fantasy scene text Extractor // @namespace Tampermonkey Scripts // @match *://game.granbluefantasy.jp/* // @match *://gbf.game.mbga.jp/* // @grant GM_log // @grant GM_setClipboard // @version 1.0 // @author MEE // @description This userscript extracts text content from story scenes in Granblue Fantasy and copies it to the clipboard. It monitors changes in the story interface and triggers text extraction when all dialogue or narration becomes visible. // @downloadURL none // ==/UserScript== (function() { 'use strict'; // Function to copy text to clipboard function copyToClipboard(text) { GM_setClipboard(text); GM_log("Text copied to clipboard:", text); } // Function to extract text content from the specific block function extractText() { var messageBlock = document.querySelector('.prt-message-area .txt-message'); if (messageBlock) { var textContent = messageBlock.textContent.trim(); copyToClipboard(textContent); } } // Function to be called after DOMContentLoaded event function main() { GM_log('Page loaded, initializing observer...'); var style = document.querySelector('.ico-cursor-talk').style.display; extractText(); const targetNode = document.querySelector('.ico-cursor-talk'); const config = { attributes: true, attributeFilter: ['style'] }; var callback = function(mutationsList, observer) { for(var mutation of mutationsList) { const currentStyle = document.querySelector('.ico-cursor-talk').style.display; if (currentStyle === 'block') { extractText(); } } }; // Create a new observer const observer = new MutationObserver(callback); // Start observing changes in the message block if (targetNode) { observer.observe(targetNode, config); } } window.addEventListener('load', main); })();