Changes between Initial Version and Version 1 of Transform2


Ignore:
Timestamp:
2009-06-13 20:47:43 (10 years ago)
Author:
speck
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Transform2

    v1 v1  
     1= How transformation script works =
     2
     3The transform javascript is executed by !GlimmerBlocker and ''not by Safari.'' The script is never sent to Safari but only the result of running the script inside the !GlimmerBlocker proxy.
     4
     5How the transformation works:
     6 1. !GlimmerBlocker retrieves the html document from the server.
     7 1. The html is stored as a simple string in the global variable {{{t}}}. It is not stored as a DOM object like browsers do.
     8 1. The transform script is executed. The script should modify the global variable to its liking by e.g. removing all <script> elements.
     9 1. The updated value of the {{{t}}} variable extracted and used for the following steps.
     10 1. Any css/js from the css/js tabs are added.
     11 1. !GlimmerBlocker sends the result to Safari.
     12
     13== Reference ==
     14
     15The content is stored in the global {{{t}}} object. See the [wiki:ObjectReference Object Reference] for all the utilities and information that !GlimmerBlocker provides.
     16
     17
     18== Html transformation examples ==
     19
     20Simple subsitution of contents:
     21{{{
     22#!js
     23t = t.replace(/documentation/, "pure void");
     24}}}
     25
     26A convenience method is provided for this, so the above code can be reduced to:
     27{{{
     28#!js
     29replace(/documentation/, "pure void");
     30}}}
     31
     32Some 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()}}}:
     33{{{
     34#!js
     35var m = t.match(/<h1><span id="item_name">(.+?)<\/span><\/h1>/i);
     36if (m)
     37        gb.setDocumentTitle(m[1]);
     38}}}
     39
     40Some sites works best without Javascript at all because they do awful things like using Flash™ where a simple <img> would suffice. A simple convenience function fixes this:
     41{{{
     42#!js
     43gb.zapScriptElements();
     44}}}
     45
     46
     47Got a good example which would improve this page?  Send it to: [feedback@glimmerblocker.org]
     48
     49== xml samples ==
     50
     51Look at the feedburner rule in the 'Site-specific ad removal' filter.