Gurdip_Sira_172
May 05, 2016Nimbostratus
Embedding javascript into pages help required
Hi,
I have a small javascript that I'd like to embed onto every page of my web application (SharePoint 2013). The js is to monitor the application end user experience. I've tried a number of approaches, like using stream profiles, iRules, etc, but it just does not seem to work (i.e. the result should be that in fiddler I see traffic to the management server). I've seen such strange behaviour such as the js is displayed on the page itself.
What's the best way to do this?
The script itself is this:
when RULE_INIT {
set static::jscript {
insert javascript code here
}
}
when HTTP_REQUEST {
Explicitly disable STREAM and COMPRESS by default for each request so it doesn't stay enabled for subsequent HTTP requests on the same TCP Connection
Stream will be enabled explicitly upon JavaScript insertion
STREAM::disable
COMPRESS::disable
If using F5 TM v 10.0 - 10.2.0, please comment out the HTTP::path line and uncomment HTTP:uri line to bypass a known issue where the query string is truncated if present
Logged with F5 as CR142756
HTTP path is more efficient to use as HTTP uri includes the query string, so it is the default way to obtain the HTTP path
set page_extension [string tolower [HTTP::uri]]
set page_extension [string tolower [HTTP::path]]
}
when HTTP_RESPONSE {
if { [HTTP::status] == 200 } {
if {[HTTP::header value Content-Type] contains "text"} {
set stream_find ""
set stream_find_lower ""
set stream_repl ""
set insertJscript 1
Do not allow the Javascript insertion if the pages end with the following
switch -glob $page_extension {
"*.ashx*" -
"*.asmx*" -
"*.axd*" -
"*.js*" {
set insertJscript 0
}
default {
if { [HTTP::payload] contains "META HTTP-EQUIV=\"Refresh\""} {
set insertJscript 0
}
}
}
if {$insertJscript == 1} {
append stream_repl $static::jscript
append stream_expression "@$stream_find@$stream_find$stream_repl@"
append stream_expression "@$stream_find_lower@$stream_find_lower$stream_repl@"
STREAM::expression $stream_expression
STREAM::enable
set stream_expression ""
}
}
}
}