Skip to content

Instantly share code, notes, and snippets.

@colleowino
Created November 14, 2017 01:47
Show Gist options
  • Save colleowino/69ee6dd39680bbc3b74e481f559d7561 to your computer and use it in GitHub Desktop.
Save colleowino/69ee6dd39680bbc3b74e481f559d7561 to your computer and use it in GitHub Desktop.
Creating Dom element and adding it to the document
document.addEventListener('DOMContentLoaded', function() {
var checkPageButton = document.getElementById('checkPage');
checkPageButton.addEventListener('click', function() {
chrome.tabs.getSelected(null, function(tab) {
d = document;
var f = d.createElement('form');
f.action = 'http://gtmetrix.com/analyze.html?bm';
f.method = 'post';
var i = d.createElement('input');
i.type = 'hidden';
i.name = 'url';
i.value = tab.url;
f.appendChild(i);
d.body.appendChild(f);
f.submit();
});
}, false);
}, false);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment