How transformation script works
How the transformation works:
- GlimmerBlocker retrieves the html document from the server.
- The html is stored as a simple string in the global variable t. It is not stored as a DOM object like browsers do.
- The transform script is executed. The script should modify the global variable to its liking by e.g. removing all <script> elements.
- The updated value of the t variable extracted and used for the following steps.
- Any css/js from the css/js tabs are added.
- GlimmerBlocker sends the result to Safari.
The content is stored in the global t object. See the Object Reference for all the utilities and information that GlimmerBlocker provides.
Html transformation examples
Simple subsitution of contents:
t = t.replace(/documentation/, "pure void");
A convenience method is provided for this, so the above code can be reduced to:
replace(/documentation/, "pure void");
Some sites don't provide a desciptive <title> but uses the company name for all pages. This can be fixed by extracting a resonable name from the html body and updating the <title> using the convenience function gb.setDocumentTitle():
var m = t.match(/<h1><span id="item_name">(.+?)<\/span><\/h1>/i); if (m) gb.setDocumentTitle(m);
Got a good example which would improve this page? Send it to: [firstname.lastname@example.org]
Look at the feedburner rule in the 'Site-specific ad removal' filter.