Manually injecting Amber into web pages

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Manually injecting Amber into web pages

Andy Burnett
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
Reply | Threaded
Open this post in threaded view
|

Re: Manually injecting Amber into web pages

Ankh'nAton
Hi,

my first guess..

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


Tom
Reply | Threaded
Open this post in threaded view
|

Re: Manually injecting Amber into web pages

Andy Burnett
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

On Fri, Nov 30, 2012 at 6:42 AM, Tom <[hidden email]> wrote:
Hi,

my first guess..

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


Tom