I am making an engine on Scratch that works with a bookmarklet to provide more functionality without creating a Scratch extension. I have had no trouble reading variables through the DOM when they are showing. However, I am trying to find a way to change the values of the variables so that the bookmarklet can return data to the engine instead of just reading data. The link to the project is https://scratch.mit.edu/projects/574836102/. I have searched Google and read the Blockly documentation, and couldn't find anything. Scratch has also appeared to have removed the "Blocks", "Variables", and "JavaScript" from the Blockly object. Does anyone know a way that I can write to project variables so the project can read them?
-
2Please provide enough code so others can better understand or reproduce the problem. – Community Oct 03 '21 at 19:00
1 Answers
i have not found a way to make a Bookmarklet change a Variable, but i found an other idea...you could make in your scratch project a [ASK()] block and insert text in to the answer. i found 2 bookmarklets 1 does the inserting text and the other presses the enter button, but i did not found a way to get it displayed in the answer Variable... i think the problem is it does not record it as a Users input and does not store it... https://scratch.mit.edu/projects/610547353/ my remix press space and then 1st bookmarklet and 2ond bookmarklet.
First bookmarklet
javascript: var els=document.getElementsByClassName("question_question-submit-button_3nYah"); if(els.length == 0) alert("Button not found"); else els[0].click();
Second Bookmarklet
javascript:(function(a){a.value=a.value.slice(0,a.selectionStart)+"Hello"+a.value.slice(a.selectionEnd);})(document.activeElement);

- 3
- 5