Hi,
I'm trying to create content on the fly and on demand, by registering
a callback using GM_registerMenuCommand. However, I'm not able to
consistently see the result of that callback. For example:
// ==UserScript==
// @name Test Greasemonkey on Amazon
// @description Test Greasemonkey on Amazon
// @include
http://www.amazon.com/*
// ==/UserScript
// Register this cool app
function registerUserMenu() {
GM_registerMenuCommand('Test', showTest);
}
function showTest() {
var element, cell;
element = document.createElement("div");
cell = document.createTextNode((new Date()).toLocaleString());
element.appendChild(cell);
var body = document.getElementsByTagName("body")[0];
body.appendChild(element);
GM_log("Inserted");
}
//showTest();
window.addEventListener("load", registerUserMenu, false);
// ---------- ---------- ---------- ----------
When going to the test web site (
amazon.com for example, then the
Kindle page), often times when I click on the user script menu item, I
can see the test message is logged into the error console, but the
test div has not been added to the page content. If I refresh the
current page, the test menu would always work. What gives?
I'm using the latest GM addon with FF 2.0 and 3.0b5.
Thanks.
- alex