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?
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);
Related
Hi guys I have a problem which I have couldn't solve after researching for quite some time. It is the following:
The copying of text from the GUI of another application (without having access to the other application programmatically)
For example:
copy the text of a word file while the application is open and is being worked on.
copy the text of an email while a email application is open and is being worked on.
I am not even sure if this is possible but would love any suggestions.
you can capture the screen then use OCR's technique to extract text from image.
My father has asked me to make him a program that has places for him to write text, a drop down, and a few places to put pictures. This program will then export the above to a word document (basically it’s just a template to make writing word documents faster for the same task)
Rather than me learn how to use python GUI programming, I figured it might be easier to just make him a local .html file for him to open, fill out, and click submit for it to be exported as a word file. Is such a thing easy or possible with html and JavaScript? I know JavaScript sort of goes against writing to the users system
You could use Docx.js - it was made to solve this issue
Full disclosure: I am very much a neophyte Applescript person (and Javascript). I have spent several hours trying to figure this out on my own, searching the Internet and trying many variations of Applescript, but no luck. I'm at a dead end without some help.
I'm modifying an Applescript that opens several web pages to lookup a word in Latvian - a language that I'm studying. The word I'm searching goes in the URL for most pages (i.e. Google Translate); however, the best dictionary I've found uses a simple form to enter a word - I can't embed the word in the URL. So, I've been trying to figure out how to enter the word on the form and "click" submit (Meklēt=search on the page in question).
The website in question is: http://www.latvianforyou.com/cgi-bin/l.pl
Here's the latest version of the Applescript I've tried:
tell application "Google Chrome"
activate
delay 3
execute javascript "document.getElementsByName('word').childNodes[0].value={{!VAR1}}"
execute javascript "document.forms[0].submit()"
end tell
The script doesn't seem to do anything. I get a "missing variable" back in the Applescript editor; I'm not sure that's an error. I've read that it simply means a null value was returned.
VAR1 is the word I'm searching/looking up and I know that variable is working - at least in the URLs of the other sites I'm searching. In any case, I have also tried directly entering the search term: "...value="akmens"" and "...value=123"" (akmens is "stone" in Latvian). However, nothing is entered into the search field.
I used the Inspect feature within Chrome to find the name of the input field, which is "word": ().
The page does open with my Applescript; it is the last tab in a new Chrome window (the other tabs in that Chrome window are the other sites that I'm searching). The script above switches over to Chrome to the correct tab - with the site I'm having trouble with. IOW - I don't think that selecting the correct Chrome window/tab is an issue.
I'm hoping that my mistake is relatively simple/easy to fix. If not - if entering some text in this field and "clicking" submit/search is much more complex, then I may just bag it and enter the word on that site manually.
Thanks very much in advance for any help.
Cheers
You may have already solved this but I have 2 possible solutions for you
pass in a full url such as
http://www.latvianforyou.com/cgi-bin/l.pl?word=1234
Use safari as I think Chrome is now broken
set thejavascript to "correctly_formatted_js"
tell application "Safari"
activate
do JavaScript (thejavascript & ";") as text in document 1
end tell
JAYTEE
I am trying to create an interactive tutorial for learning an API. I've been googling my options for an entire day now. I came across ace, code mirror etc. but I'm not sure how I can use them in my case.
What I wish to do is that when the user clicks a button, a javascript code linked to it should open up in an editor on the same webpage. This would aid the users to see how the code is working and give them scope to modify and learn.
I know its not a constructive question but any help is appreciated! Thanks!
you can just wantch here how it is done
They made it with knockout MVVM but you can use angular or anything else you like.
I used tags to store my code and displayed it using codemirror's setValue property mentioned by #georg.
Im annoyed that this doesn't seem possible, but i wanted to check with the community to see if someone has developed a working version of something similar.
I'm a graduate student and spend a LOT of time online researching, and when I find that sweet paragraph that makes just the argument I've been searching for, I've gotta copy and paste it out of chrome (on mac os x) and into word (2011). I've built a "strip all formatting" macro that works well enough, but what i would like is a pipe from chrome into my open word document that gives me 1 key "send selection to word document" (like ~).
I've got the js working to get selected text and move it around, but i cannot seem to open the document i want to move the text into. Ideally, this would work as a chrome plugin (I've built them before), but I've seen no documentation about JS => Word on other platforms (obviously activeX controls dont work for me).
Any suggestions?
You can use an automator service to do this. Open Applications > Automator, and then create a service, which receives selected text (one of the built in defaults). This works in any app, and is accessible via the Services menu when you right click.
You can do this easily with TextEdit for example using these two actions:
Service receives selected text
New Textedit Document.
I've just tried it to confirm it. It can also copy rich text etc (including links) if you want. I imagine something similar is possible with word, and there is a built in service already to do the same if you have installed TextWrangler (another word processor).
JavaScript is contained within the browser for security reasons, so you will not be able to do it with JavaScript.
The best thing that i can come up with is to write a 'bot' kinda thing that just coppy pastes, so not for in an extention.