Post Reply 
A proper way to put code before </head> tag
Dec. 10, 2010, 11:29 PM
Post: #1
A proper way to put code before </head> tag
May be it's already answered, but I'm hoping for a simple answer here.

It's a common desire to put some HTML code (for example, a custom <style> block) right in front of ending </head> tag.

What is the best way to do it with Sidki's filter sets?

Is it something like this?
Code:
Match = "</head>"
Replace = "<style type=\"text/css\"> ... </style>$STOP()"
Note: there is no </head> at the end of "Replace" section. It's because the ending tag will be inserted by this filter:
Code:
"Header Bot Mark: Start - Fix </head>     09.06.29 (multi) [sd] (d.r)"
But what if this filter is 'off'? Or it should be always 'on' with these filters?

Or may be there is some better (proper) way to achieve the simple task?
Add Thank You Quote this message in a reply
Dec. 11, 2010, 12:14 AM
Post: #2
RE: A proper way to put code before </head> tag
the .r in the title means "required" and thusly ALWAYS ON...
Add Thank You Quote this message in a reply
Dec. 11, 2010, 01:22 AM
Post: #3
RE: A proper way to put code before </head> tag
For a filter in sidki's set you could try a match of

Code:
(^(^</HEAD>))$STOP()

or

Code:
(^(^<ProxHdrTop>))$STOP()

CSS can also be injected via Exceptions-U

Code:
## insert user stylesheet                       $SET(sUserCSS=CSS_NAME)
##
## By default, CSS_NAME can be one of the three included W3C core styles:
## chocolate, oldstyle, or steely.
##
## You may also write your own CSS, prefix the filename with "user-", e.g.
## "user-janedoe.css", copy it to "html\sidki_h_xxxx-xx-xx\CSS\", and invoke
## it with an entry like:
## mysite.com/                                  $SET(sUserCSS=janedoe)
## ----------------------------------------------------------------------------

HTH
Add Thank You Quote this message in a reply
Dec. 11, 2010, 05:48 AM
Post: #4
RE: A proper way to put code before </head> tag
(Dec. 11, 2010 12:14 AM)ProxRocks Wrote:  the .r in the title means "required" and thusly ALWAYS ON...
@ProxRocks - thank you!
Could you please provide a link to a doc or a page with all those conventions (if such exists). I'd like to use them in a right way. Smile!
Add Thank You Quote this message in a reply
Dec. 11, 2010, 06:53 AM
Post: #5
RE: A proper way to put code before </head> tag
@JJoe - thank you!

I've tried the first two methods (I'll try the 3rd method later) and both works well:
1st puts custom CSS after other CSS declarations (right above </header> tag)
2nd puts custom CSS at the top of all other CSS declarations
That's exactly what I need to know Smile!

My question has arrived after I discovered that for the users of IE6 my "Google Light Theme" small filtering package (it's published here) becomes incompatible with the latest 2010-10-23 Sidki set. (I use IE7 all the time and just noticed that problem with IE6 and the new set). The new set caused Google to send search results page with a special format (different from other browsers). It happens when it gets "User-Agent MSIE 6.0" (the new filter set starts to send it with IE6, instead of old fake "Space Bison/0.02 [fu] (Win67; X; SK)"). And that format doesn't contain <noscript> tag (it was part of Match criteria that I used in filter). That's why I asked for help to find out the right way to put custom CSS code at the end of <header> part. Smile!

But, unfortunately, there is no happy end of the story so far. The specially formatted search results page is based on TABLE's, not on DIV's (as they send it for any other browsers and all versions of IE, except IE6). And this creates a big difficulty with getting rid of the left side bar and the empty right side bar Sad

So, now it seems that the only solution to run those "Google Light Theme" filters with the new 2010-10-23 set and IE6 is to fake "User-Agent" string. And with Google's search results page - always sent fake "Mozilla/1.22 (compatible; MSIE 7.0; Windows NT 6.1)" (or containing anything else, except "MSIE 6.0"), which could be done with the help of "Exceptions.ptxt" file:
Code:
# Google Search - results pages
www.google.(*/)+{1}search\?
  $SET(0=a_ads.a_target.i_popup_b:0.i_timer:2.i_noscr:3.)
  $SET(0=f_ua_§Mozilla/1%2e22 (compatible; MSIE 7%2e0; Windows NT 6%2e1).)
(the added new 2nd line of $SET makes it happen)

But it means that all other browsers (including FF, Iron, etc) now start to get search results page with "User-Agent MSIE 7.0". It's not a big deal (as tests show), but it's not the right way to fix the problem, associated with only IE6, search results page and 2010-10-23 set...

I guess it could be avoided if there was a way to force to send a fake: (User-Agent MSIE 7.0) string only if:
1. the actual browser is IE6
AND
2. the page visited is "www.google.(*/)+{1}search\?"

But it seems that there is no such way to specify the "exception" in "Exceptions.ptxt" file. So user of IE6 should make change (see code above) in that file manually if he wants to use IE6 and (probably) to change it back, if he wants to use any other browser. Not a good thing... Sad

Thus the question is - is there a way to send a fake User-Agent string only when user uses IE6 and he visits "www.google.(*/)+{1}search\?" ?
Add Thank You Quote this message in a reply
Dec. 11, 2010, 06:38 PM
Post: #6
RE: A proper way to put code before </head> tag
What is the actual user agent that was changed to "Space Bison/0.02 [fu] (Win67; X; SK)"? I don't see that here yet or remember it.

To answer the question, the exceptions lists run before a user-agent header filter sets the variable hOrigUA. hOrigUA eventually contains the original User-Agent.

I think something like

Code:
www.google.(*/)+{1}search\? (
  $OHDR(user-agent:*msie 6) $SET(0=a_ads.a_target.i_popup_b:0.i_timer:2.i_noscr:3.f_ua_§Mozilla/1%2e22 (compatible; MSIE 7%2e0; Windows NT 6%2e1).)
  |$SET(0=a_ads.a_target.i_popup_b:0.i_timer:2.i_noscr:3.)
  )

in Exceptions should do what you want.

In Exceptions-U

Code:
www.google.(*/)+{1}search\? $OHDR(user-agent:*msie 6) $SET(0=f_ua_§Mozilla/1%2e22 (compatible; MSIE 7%2e0; Windows NT 6%2e1).)

A header filter could also work. The problem that I see with header filters is that their order of application can be important and my Win7 machine doesn't always put new ones where they belong.

Code:
[HTTP headers]
In = FALSE
Out = TRUE
Key = "! * 999 User-Agent: fake IE7 for IE6 for OZO (Out)"
URL = "www.google.(*/)+{1}search\? $OHDR(user-agent:*msie 6)$SET(keyword=$GET(keyword)f_ua_§Mozilla/1%2e22 (compatible; MSIE 7%2e0; Windows NT 6%2e1).)"

Seems to order correctly after saving the new config several times and work.

The set's documents are in the "sidki-etc" folder. You should be able to access them by opening the Proxomitron's Web Page filter editor and testing the filters in the "NAOKO 4.5 CONFIG -- SIDKI 2010-10-23 -- README" section. Also, available at http://sidki.proxfilter.net/prox-docs.html or http://sidki.host22.com/prox.html .

HTH
Add Thank You Quote this message in a reply
Dec. 12, 2010, 06:32 AM
Post: #7
RE: A proper way to put code before </head> tag
@JJoe - Thanks a lot! All three ways are working well. Smile!

(Dec. 11, 2010 06:38 PM)JJoe Wrote:  What is the actual user agent that was changed to "Space Bison/0.02 [fu] (Win67; X; SK)"? I don't see that here yet or remember it.
My archive "Proxo-sidki_09-02-13.zip" contains "IncludeExclude.ptxt" file with this code:
Code:
#  Last updated 2009-06-05
...
# Google Search
www.google.[^/]+/(intl/[^/]+/(^?)|search\?|webhp|(^?))
  $SET(0=a_ads.a_rdlink.a_target.i_popup_b:0.i_timer:2.i_noscr:3.f_cookie.
  f_ua_§Space Bison/0%2e02 [fu] (Win67; X; SK).)
  $SET(sCookieP=0)$SET(sCookieF=PREF=ID=3003added0032123:FF=4:NR=100:CR=2:SG=0)
...
.Original package of those old filters contains this code:
Code:
#  Last updated 2009-02-12
...
# Google Search
www.google.[^:/]+/(intl/[^/]+/(^?)|search\?(^q\=cache:)|webhp|(^?))
  $SET(0=a_ads.a_rdlink.a_jslink.a_target.i_popup_b:0.i_timer:2.f_cookie.)
  $SET(1=dlink_b:0.)$SET(sCookieP=0)
  $SET(sCookieF=PREF=ID=3003added0032123:FF=4:NR=100:CR=2)
...
Frankly I have no idea now where I get it from in my package... But I always thought, that it was an official file. And AFAIK, all Google theme modification filters work just fine with it.

What would you suggest now? Tell everyone who uses IE6 to add lines from your previous post into "Exceptions.ptxt" file (as it's similar to what we had with 2009-02-13 set)? Or add new line into "Exceptions-U.ptxt" file (as it looks simple to me)? Or put [HTTP headers] filter into "default.cfg" file?

I think all IE6 users would prefer to see the new DIV-based search page (sent to all other browsers, except IE6), rather then the old, TABLE-based search page (which Google by some weird reason sends to IE6 users now). It means that faking "User-Agent" string for IE6 in Google search page could be considered a better deal for all and potentially be included in a common filter set. Don't you think?
Add Thank You Quote this message in a reply
Dec. 12, 2010, 09:11 PM
Post: #8
RE: A proper way to put code before </head> tag
It came from the 09.07.06 update.

"Exceptions.ptxt" should belong to the publisher of the set as 'unofficial' modifications to it ( and some other files ) may make it difficult to help users.

So, for now, I think it is best for us to use "Exceptions-U.ptxt" and or filters to add routines. I'd guess that most people would rather import filters than edit "Exceptions-U.ptxt". It should be easy enough to add these things to an official set if necessary.

The alternative is for everyone to keep two copies of the set, an unaltered and a 'working'.

I wonder, is Google's code changing too often to be targeted for extensive 'alternate display' in the base set? I'm still seeing several US versions for Firefox3. I think Firefox2 was getting different code than Firefox3.

Also wondering why, display or security, Google is sending this code to IE6.
Add Thank You Quote this message in a reply
Dec. 13, 2010, 04:09 AM
Post: #9
RE: A proper way to put code before </head> tag
(Dec. 12, 2010 09:11 PM)JJoe Wrote:  "Exceptions.ptxt" should belong to the publisher of the set as 'unofficial' modifications to it ( and some other files ) may make it difficult to help users.
I agree with you. And this thread - Google Light Theme - fixed 2010-05-06 - is a good example of such problem. I always thought that other users use the same set of filters as I do and assumed that if the filter was working for me - it was working for everybody. Which, as we see now, was not the case Sad The only way to have a control over a new custom filter is to keep some base environment (e.g. 2010-10-23) and keep track on what specifically should be changed in that set in order to make the new custom filter working. And that's exactly what I'm, going to do with that thread next.

Quote:So, for now, I think it is best for us to use "Exceptions-U.ptxt" and or filters to add routines. I'd guess that most people would rather import filters than edit "Exceptions-U.ptxt". It should be easy enough to add these things to an official set if necessary.
If I get your point correctly, from the perspective of an easy way to add new filters in future official sets (if necessary) the best way to do it now (and in this particular case, to make this IE6 exception) is to use "Exceptions-U.ptxt" rather then to put corresponding filter into "default.cfg". Right?

Quote:Also wondering why, display or security, Google is sending this code to IE6.
I don't have an answer to this question. And as I've mentioned earlier, additionally to the different layout (TABLEs instead of DIVs), IE6 version doesn't have <noscript> code. Other versions of IE get this code. Do Google developers assume that IE6 users always use JavaScript? Or they just want to "punish" them if they don't? It looks strange...
Add Thank You Quote this message in a reply
Dec. 13, 2010, 09:33 AM
Post: #10
RE: A proper way to put code before </head> tag
(Dec. 13, 2010 04:09 AM)OZO Wrote:  Do Google developers assume that IE6 users always use JavaScript?

probably a safe assumption, actually...
it seems to me that the "majority" (i did not say "all", lol) of IE6 users are "grandma types" that bought a computer YEARS ago and have never upgraded hardware or software since buying that computer that *CAME WITH* IE6 *and* was set up to "use JavaScript" BY DEFAULT...

Smile!


i mean, seriously, think about just what the "demographics" are for IE6 users... here's a ZDNet article on it - http://www.zdnet.com/blog/btl/ie-6-nearl...nter/35218

4.7% of the US market, a little over 12% for the global market...
and as one of the comments indicate, CHINA accounts for the largest segment of IE6 users because of *PIRATED* versions of Win XP !!!

Sure, i still have a machine running Windows 2000 - and it is "stuck" on IE6... but i don't "use it" to browse anyway... and when i do, that machine has Opera installed and set as default... but back to the demographics - "grandma types" don't use Opera... Big Teeth
Add Thank You Quote this message in a reply
Dec. 14, 2010, 02:45 AM
Post: #11
RE: A proper way to put code before </head> tag
(Dec. 13, 2010 04:09 AM)OZO Wrote:  If I get your point correctly, from the perspective of an easy way to add new filters in future official sets (if necessary) the best way to do it now (and in this particular case, to make this IE6 exception) is to use "Exceptions-U.ptxt" rather then to put corresponding filter into "default.cfg". Right?

lol, I'm not sure.

If you publish a cfg file that looks something like

Code:
[Blocklists]
List.test = "..\lists\test.txt"

[HTTP headers]
In = FALSE
Out = TRUE
Key = "! : New-HTTP-header"
URL = "Maybe some stuff here"
Match = "Maybe some stuff here"
Replace = "Maybe some stuff here"

[Patterns]
Name = "a web filter"
Active = TRUE
URL = "Maybe some stuff here"
Bounds = "Maybe some stuff here"
Limit = 256
Match = "Maybe some stuff here"
Replace = "Maybe some stuff here"

This may allow people to add the package to their set automatically via the "Merge-O-Matic". The "Merge-O-Matic" opens after you select "Merge config filters" under "File" on Proxomitron's main screen. It can merge properly formated data to the user's current cfg from a file or the clipboard. If they like, they save their new cfg. However, the merged filters may need to be moved.

The alternative is to require editing Exceptions-U.

Having written the above, I think I would require editing Exceptions-U. It looks like too few people will need this for it to take up space in the header filters. Those that do will learn how to use the set. Those that don't could add it commented out.

HTH
Add Thank You Quote this message in a reply
Dec. 14, 2010, 08:57 AM
Post: #12
RE: A proper way to put code before </head> tag
I appreciate your advices, JJoe Smile!

While "Merge-O-Matic" works well, it puts new filters only at the beginning of the configuration set. So far I'm not sure that it's the best way to do (and in particular, to suggest to do for others):
1. I prefer to keep filter set organized (in sections). For example, it'd be better to put filter mentioned earlier in section associated with Google. And I have filter set for BBR forum, which I think should be placed within "Site-Specific" section.
2. I'm not confident that order of filters is not important and will not interfere with the way how they may act. Am I worry too much (about nothing, maybe?) here?

For initial testing "Merge-O-Matic" is very helpful though...
Add Thank You Quote this message in a reply
Dec. 14, 2010, 04:26 PM
Post: #13
RE: A proper way to put code before </head> tag
(Dec. 14, 2010 08:57 AM)OZO Wrote:  Am I worry too much (about nothing, maybe?) here?

No.

(Dec. 14, 2010 02:45 AM)JJoe Wrote:  However, the merged filters may need to be moved.

Order can be important. Sometimes a filter must be first or last to act and position is the only way to specify. However, I usually try to build my mini cfgs to allow people to use the "Merge-O-Matic".
Add Thank You Quote this message in a reply
Dec. 14, 2010, 09:40 PM
Post: #14
RE: A proper way to put code before </head> tag
I see... With the import of custom .cfg files via "Merge-O-Matic" there is no way to add some lines into other files, except to "default.cfg". For example, it's impossible to upend line into "Exceptions-U.ptxt" or into "Bypass List.txt". It all should be done manually. Right?
Add Thank You Quote this message in a reply
Dec. 14, 2010, 11:07 PM
Post: #15
RE: A proper way to put code before </head> tag
(Dec. 14, 2010 09:40 PM)OZO Wrote:  I see... With the import of custom .cfg files via "Merge-O-Matic" there is no way to add some lines into other files, except to "default.cfg". For example, it's impossible to upend line into "Exceptions-U.ptxt" or into "Bypass List.txt". It all should be done manually. Right?

The "Merge-O-Matic" can only modify the current cfg file. "default.cfg" and "sidki_2010-10-23.ptron" are cfg files.
The lists must be modified by the user or replaced.

This doesn't mean you shouldn't provide a file to be merged. It just means that the user will have to edit the list, if needed.

In the past, we have had users who were "grandma types", physically impaired, technically challenged, etc.

So when I publish routines I try to make them easy to install and uninstall. I think the "Merge-O-Matic" is the easiest safe way.
Add Thank You Quote this message in a reply
Post Reply 


Forum Jump: