Closed MTRNord closed 8 years ago
Also: this aproach does most of the time just search but not click
if you have uploaded IITC should be comfortable use the special hook "search".
window.addHook('search', yourFunctionName);
does that give me the already found results? because in the iitc code I saw that always as an search handler for services to search at.
Nevermind I do see that I will try that :) (I close when it confirmed does work)
The hook return an object. there is an 'results' array. This is an example (work for the portals):
window.myFunc = function(r){
console.log(r);
if(r.results[0] && r.results[0].position && r.results[0].title !== 'No results on OpenStreetMap'){
window.map.setView(r.results[0].position);
}
}
window.addHook('search', window.myFunc);
@ZasoGD r.results[0] gives me undefinded even if the result array contains elements
You could try to fire the hook yourself and let the plugins report their results directly to your code. You just have to provide the same API for providing results as IITC. Note that results may come in asynchronously, especially for OSM and missions.
ok fixed it by doing setInterval() stuff while waiting that the array is bigger than 0
Hi I am searching for a way to do easy selecting the first search result or to at least detect if any results are there. I do that in phantomjs not as an plugin. My current code which is very unstable (because of the click() event) looks like:
is there a way to get the results without needing to do the
document.querySelector('.searchquery').childNodes[1].childNodes[0].click();
part? because it fails in 99% of my tries. Or is this impossible without doing the search myself and manually going to that position?