Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Load external JS file in Google Adwords Scripts

I'm looking for a way to load an external Javascript library to my Google Adwords Scripts IDE. I can't find anything on this in the docs or execute the JS through the URLFetchApp API (https://developers.google.com/apps-script/reference/url-fetch/). Have anyone tried this or have any ideas?

I know one can do this in for example JQuery, but from what I can see in the source code, the way they implement it is by adding a HTML script-tag and let the browser load it. Since I'm not in a browser in this environment, this will not be possible.. I guessing I'm in some V8-engine environment.

like image 385
Niklas9 Avatar asked Apr 08 '13 10:04

Niklas9


1 Answers

I managed to get this working by:

function main() {
  var url = "http://example.com/asdf.js";
  eval(UrlFetchApp.fetch(url).getContentText());
}

eval isn't sandboxed away obviously! :)

like image 162
Niklas9 Avatar answered Sep 22 '22 17:09

Niklas9