Question : Greasemonkey script to add text at the bottom of aweb page

Hi Team,

   I am new to Greasemonkey scripting and my request is very simple.   without doing any element ID queries or any of the Xpath stuff, I just want to add text at the bottom of my web page.

If my test page is a simple:

<html><body><h1>It works!</h1></body></html>

and I just want to add "THIS TEXT is INSERTED" after the "It works" line, how do i do it?

i found a sample script but it doesn't work on my simple query.   How can I get it work on my page?

thanks and regards,
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
// ==UserScript==
// @name           append-content
// @namespace      http://localhost
// @description    append something to localhost web page
// @include        http://localhost
// ==/UserScript==

var logo = document.createElement("div");
logo.innerHTML = '<div style="margin: 0 auto 0 auto; ' +
'border?bottom: 1px solid #000000; margin?bottom: 5px; ' +
'font?size: small; background?color: #000000; ' +
'color: #ffffff;"><p style="margin: 2px 0 1px 0;"> ' +
'THIS TEXT is INSERTED' +
'</p></div>';
document.body.insertBefore(logo, document.body.lastChild);
}

Answer : Greasemonkey script to add text at the bottom of aweb page

It should work. what about removing the last bracket as it will cause the script to fail.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<script type="text/javascript">
window.onload = function() {
	var logo = document.createElement("div");
	logo.innerHTML = '<div style="margin: 0 auto 0 auto; ' +
		'border-bottom: 1px solid #000000; margin-bottom: 5px; ' +
		'font-size: small; background-color: #000000; ' +
		'color: #ffffff;"><p style="margin: 2px 0 1px 0;">' +
		'THIS TEXT is INSERTED' +
		'</p></div>';
	document.body.insertBefore(logo, document.body.lastChild);
}
</script>
</head>

<body><h1>It works!</h1></body>
</html>
Random Solutions  
 
programming4us programming4us