Skip to content

Instantly share code, notes, and snippets.

@me7
Created February 8, 2017 02:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save me7/3d09a3da818093a3a26892b53613e355 to your computer and use it in GitHub Desktop.
Save me7/3d09a3da818093a3a26892b53613e355 to your computer and use it in GitHub Desktop.
Inject mithril to webpage
//press F12 to open chrome dev tools
//then add mithril to header
var mt = document.createElement('script');
mt.src = "https://unpkg.com/mithril/mithril.js";
document.getElementsByTagName('head')[0].appendChild(mt);
//test render
m.render(document.body,"Hello");
//let create link and click
m.render(document.body,m("a#link",{href:"https://dab1nmslvvntp.cloudfront.net/wp-content/uploads/2016/02/1454335918es6-arrow-functions-new-fat-and-concise-syntax-in-js05-no-parameters.png"},"click"))
var l = document.getElementById("link")
l.click()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment