[Greasemonkey] insert comment top html document

Jim Roberts jimmyroberts at gmail.com
Fri Feb 10 04:50:29 EST 2006


On 2/10/06, Bill Donnelly  wrote:
> I want to write a GmScript that inserts a comment at the top of each
> html document that contains the URL source address, so when the source
> is saved, the URL of the document is automatically included for reference.
>
> So, for example, if the top of a document has:
>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
> <html>
> <head>
>
> I want to make it:
>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
> <!-- source = http://www.domain.TLD/directory/whatever.html -->
> <html>
> <head>

var
html = document.getElementsByTagName('html')[0],
comment = document.createComment(' source = '+ location.href + ' ');

html.parentNode.insertBefore(comment, html);


More information about the Greasemonkey mailing list