I have made a simple omnibox extension for Chrome, The idea is you enter a postal code, press enter and it opens a few websites. But it does not work how i want to
function resetDefaultSuggestion() {
chrome.omnibox.setDefaultSuggestion({
description: 'Postcode: Zoek de postcode %s'
});
}
resetDefaultSuggestion();
chrome.omnibox.onInputChanged.addListener(function(text, suggest) {
// Suggestion code will end up here.
});
chrome.omnibox.onInputCancelled.addListener(function() {
resetDefaultSuggestion();
});
function navigate(url) {
chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
chrome.tabs.create({url: url});
});
}
chrome.omnibox.onInputEntered.addListener(function(text) {
navigate("http://www.gevonden.cc/postcode/" + text + "/streetname,housenr/");
navigate("http://www.nummerzoeker.com/?color=white&lastname=&str=&hnr=&pc=" + text +"&pl=&phone=&maxrows=100&sort=3&search=Zoeken");
navigate("http://www.zoekenbel.nl/postcode.asp?zoekop=p&zoek=postcode&postcode=" + text + "&Huis_nr=");
navigate("https://server.db.kvk.nl/TST-BIN/ZS/ZSWWW01@?TAAL=NL++&TYPE=PCHN&AANT=0&AWCD=" + text + "&NHVC=&HIST=+&submit=");
});
chrome.omnibox.onInputEntered.addListener(function(text) {
navigate("http://www.funda.nl/koop/zoeksuggestie/" + text + "/");
});
This all works ok, the last website (http://www.funda.nl/koop/zoeksuggestie/ + text) does not work perfectly, when the page loading is complete a button needs to be clicked, to display the results. When I run the following in the console, it works.
document.querySelectorAll("input[type='submit']")[0].click();
How do I add this to the extension so it waits for the page to load completely and then clicks the button?
Thanks in advance, LTKort
PS This is the first time making an extension and the first time coding in JS?!