-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error : unable to locate menu element #14
Comments
thanks for the feedback. seems like it still works for me on the old DOM path. i think google uses different UIs for different regions, so maybe that could be it. there used to be ways I can trigger that error if I do things like interrupting the loading of the page before it's completely loaded in the dom for the menu. i can't seem to reproduce it right now though. |
Actually, I think we 've got the same DOM :) I checked with jquery when the page was loaded and the <<//div[@Class="nav-section-divider">> is here: I'm pretty sure that, with me, the page isn't fully loaded when the addui function is called. Because I tried to set a timeout and it worked perfectly this time :/ This code doesn't work: var addui = function() {
var ui = new XDoc(document);
//var menu = ui.search('//div[@id="music-content"]')[0];
var menu = ui.search('div[@class="nav-section-divider"]')[0];
var inputui = ui.create('input',false,{'type':'file'});
var importui = ui.create(
'div',[ui.create('h4','Import Playlists'),inputui]);
var exportlink = ui.create('a','Export Playlists',{'href':'#exportCSV'});
var exportui = ui.create('div',ui.create('h4',exportlink));
var statusout = ui.create('h6','ready');
var statusui = ui.create('div',[statusout]);
stat.element = statusout;
var exporter = new Exporter();
exporter.listenTo(exportlink);
var importer = new Importer();
importer.listenTo(inputui);
if (menu) {
menu.appendChild(importui);
menu.appendChild(exportui);
menu.appendChild(statusui);
} else {
console.log('unable to locate menu element');
}
};
window.addEventListener ("load", addui, false); But that dirty code works ;) : var addui = function() {
setTimeout(function(){
var ui = new XDoc(document);
var menu = ui.search('//div[@class="nav-section-divider"]')[0];
var inputui = ui.create('input',false,{'type':'file'});
var importui = ui.create(
'div',[ui.create('h4','Import Playlists'),inputui]);
var exportlink = ui.create('a','Export Playlists',{'href':'#exportCSV'});
var exportui = ui.create('div',ui.create('h4',exportlink));
var statusout = ui.create('h6','ready');
var statusui = ui.create('div',[statusout]);
stat.element = statusout;
var exporter = new Exporter();
exporter.listenTo(exportlink);
var importer = new Importer();
importer.listenTo(inputui);
if (menu) {
menu.appendChild(importui);
menu.appendChild(exportui);
menu.appendChild(statusui);
} else {
console.log('unable to locate menu element');
}
}, 3000);
};
window.addEventListener ("load", addui, false); Strange isn't it ? |
@Glecun Thanks for providing that fix! You really saved my day. |
Hi,
I've got the message: "unable to locate menu element" in the console when I load the page with the script enabled.
I think the error is here:
var menu = ui.search('//div[@class="nav-section-divider"]')[0];
He can't find it anymore for some reason... Maybe the HTML has been updated :/
So I replaced it with
var menu = ui.search('//div[@id="music-content"]')[0];
Just for you know ;)
The text was updated successfully, but these errors were encountered: