Forum Discussion
Accessing Text from a Text box using new API
- 2 months ago
I did some digging. If you want to access the text from a storyline textbox object, you can use the object ID. Which in the DOM, is the "data-model-id" Once you search for that, you should be able to find the text box and get the text. Here is some script that will allow you to copy onscreen text into a variable dynamically. Therea are things that this could be useful for. Once is to have offscreen text that you could feed to AI as a source of content.
setTimeout(() => { // Replace '6lfv6DK2C7k' with the actual data-model-id value const container = document.querySelector('[data-model-id="6lfv6DK2C7k"]'); if (!container) return; // Then search for the <tspan> (or <text>) that actually contains your text const textElem = container.querySelector('text tspan'); if (!textElem) return; const rawText = textElem.textContent.trim(); console.log('Extracted text:', rawText); // If you want to set a Storyline variable: const player = GetPlayer(); player.SetVar('myBox', rawText); }, 100);
I did some digging. If you want to access the text from a storyline textbox object, you can use the object ID. Which in the DOM, is the "data-model-id" Once you search for that, you should be able to find the text box and get the text. Here is some script that will allow you to copy onscreen text into a variable dynamically. Therea are things that this could be useful for. Once is to have offscreen text that you could feed to AI as a source of content.
setTimeout(() => {
// Replace '6lfv6DK2C7k' with the actual data-model-id value
const container = document.querySelector('[data-model-id="6lfv6DK2C7k"]');
if (!container) return;
// Then search for the <tspan> (or <text>) that actually contains your text
const textElem = container.querySelector('text tspan');
if (!textElem) return;
const rawText = textElem.textContent.trim();
console.log('Extracted text:', rawText);
// If you want to set a Storyline variable:
const player = GetPlayer();
player.SetVar('myBox', rawText);
}, 100);