Manually injecting Amber into web pages

42 views
Skip to first unread message

Andy Burnett

unread,
Nov 29, 2012, 9:39:36 PM11/29/12
to amber...@googlegroups.com
Every so often, I want to do something to a webpage. It might have a table that I want to extract every nth item or temporarily remove some items etc etc.

Usually, I go into the Chrome Dev Tools, and hack about in the console. However, what I would really like to do is to force amber into the page, and be able to do things with the Smalltalk environment. Unfortunately, I am close, but I must be doing something wrong - or it isn't possible.

What I have tried is:

scripttag = document.createElement('script');
document.getElementsByTagName('head')[0].appendChild(scripttag);
loadAmber();

This nearly works, but I get error messages where the browser is trying to load e.g. amber.css from the hostname rather than from the dropbox path. So, obviously, it doesn't find it.

What am I doing wrong? Or, is this a same origin problem, and I can't get around it?

By the way, the files don't have to be in Dropbox. I was using that as a quick hack.

Cheers
Andy

Tom

unread,
Nov 30, 2012, 6:42:10 AM11/30/12
to amber-lang
Hi,

my first guess..

stylettag = document.createElement('style');
styletag.src="http://path/to/amber.css";
document.getElementsByTagName('head')[0].appendChild(styletag);
...
...
loadAmber();


Tom

Andy Burnett

unread,
Nov 30, 2012, 1:24:31 PM11/30/12
to amber...@googlegroups.com
Thanks Tom,

Turns out the fix was very simple. I just changed the value of 'home' in the amber.js file to point to the dropbox directory. I can now insert the full Amber IDE into any page, and start hacking around.  It is a good enough fix until someone creates a chrome add-on to do it for me :-)

Cheers
Andy
Reply all
Reply to author
Forward
0 new messages