"<script> Remove: Ad Scripts - Noscript Test 10.11.03" isn't intended to be a replacement.
Consider it to be a diagnostic aid for now. I hope it works as I expect.
Default behaviour:
1. Matches the same code as sidki's filter but may not remove same.
2. The script or two scripts that are matched by (<script*</script > )+{1,2} and are closest to the noscript block may be removed.
Remaining scripts are returned to the buffer for other filters to evaluate.
When there are more scripts than those matched by (<script*</script > )+{1,2} in the script-noscript block, the
event is logged to Log-Rare as "WEB JS_Ad_HTM noscript2+".
3. All matched scripts may be removed when the script or scripts closest to the noscript block are not matched by (<script*</script > )+{1,2}.
Event is logged to Log-Rare as "WeirdScript".
Optional behaviour:
Setting a variable named "ScriptNoscriptFull" to "Full" will cause the filter to remove all scripts possible.
Code:
[Patterns]
Name = "<script> Remove: Ad Scripts - Noscript Set Full flag"
Active = FALSE
URL = "$TST(hCT=*html)$TST(flag=*.adurl:1.*)(^$TST(keyword=*.(a_js|i_noscr:[12]|i_level:[12]).*))"
Limit = 2
Match = "$SET(ScriptNoscriptFull=Full)nevermatch(^)"
Name = "<script> Remove: Ad Scripts - Noscript Test 10.11.03 (multi) [sd] (d.2 l.3)"
Active = TRUE
Multi = TRUE
URL = "$TST(hCT=*html)$TST(flag=*.adurl:1.*)(^$TST(keyword=*.(a_js|i_noscr:[12]|i_level:[12]).*))"
Limit = 20000
Match = "$SET(SBlock=)"
"($NEST(<script(^$TST(tNoscript=1+void)|$TST(comment=2))$TST(script=1*),>)( $NEST(<script,>))+"
"$INEST(<script,</script)</script(*>)+{1}"
"([ \t\r]+(\n[ \t\r]+)+{0,2}$NEST(<script,>)( $NEST(<script,>))+$INEST(<script,</script)</script*>)+"
"&&"
"(\1(<script*</script > )+{1,2}(^?)$SET(SBlock=\1))+"
"|?+$ADDLST(Log-Rare,WeirdScript \t\u)"
")"
" ($NEST(<noembed,</noembed >) )+($NEST(<!--,-- >) )+"
"("
"<noscript(*>)+{1}$SET(tNoscript=$GET(tNoscript)void)"
" (^<(/noscript|html|body|frameset?+{1024}))(\4)</noscript >"
")\5"
"$SET(scriptt=$GET(script))"
"&$TST(\4="
"(^$TST(keyword=*.(a_track|i_noscr:3).*))"
"(<(div|p(^[a-z]))\8(*>)+{1} |($NEST(<!-(-)\8,-- >) )+)"
"(<img(*>&&("
"(*width(=\\+"+| :) ([#*:4])\6*&&*height(=\\+"+| :) ([#*:4])\7$SET(9=Webbug \8 \6x\7)*)"
"|(^*(width [=:]|src=$AV(*.jpe+g))|(*src=$AV(*.gif)&*(alt=$AV(?*)|usemap=)))$SET(9=Webbug \8 nodim)*"
")) )+{1,*}(^?+{100})*"
"|<iframe($TST(flag=*.iframe_b:\2.*)|)("
"$TST(\2=[12])|(^$TST(\2=0))[^>]++src=$AV("*|[^/.]+//(^"
"api.recaptcha.|www.google.com/recaptcha/|"
"([^/]++.|)$TST(uDom)(^.))*|*.swf*))$SET(9=iFrame)*"
"|(*\s(src|href|action|data)\3=)++{1,2}$AV( $LST(AdList)*)*"
"&"
"($TST(script=1*1*)|*<(frameset|iframe)\6$SET(script=void))"
"$SET(2=<script type="text/javascript">/*\r\n\tPROX: Empty script"
" left in place to keep the noscript \6.\r\n*/</script>\r\n\5)"
"|($TST(tNoscript=(1*)\2void)$SET(tNoscript=\2)|$SET(tNoscript=))$SET(script=)$SET(2=)"
")"
"&"
"$TST(ScriptNoscriptFull=Full)$SET(SBlock=)$SET(scriptt=)"
"|$TST(SBlock=?*)$SET(script=$GET(scriptt))$SET(scriptt=)"
"|$SET(SBlock=)$SET(scriptt=)"
"&"
"$SET(eAdJS=$GET(eAdJS)"
"%3Cspan class=%22Pr0xFly-Span%22%3E$GET(mHead) Noscript:%3C/span%3E"
" $ESC(\9)%3Cbr class=%22Pr0xFly-Br%22 /%3E"
")"
"$SET(1=$TST(keyword=(^$TST(tFrameset=*))*.i_level:5.*)"
"<span class="Pr0x Pr0xAdScript" style="display:$GET(displayD)">"
"• JS Ad Noscript: \9</span>"
")"
"($TST(SBlock=?*)$ADDLST(Log-Rare,WEB JS_Ad_HTM noscript2+ \3 \t\9 \t\u)|)"
"($TST(volat=*.log:2*)(^$TST(SBlock=?*))$ADDLST(Log-Main,[$DTM(d T)]\tWEB JS_Ad_HTM noscript \3 \t\9 \t\u)|)"
Replace = "$GET(SBlock)$SET(SBlock=)\r\n"
"\1<!-- PROX: Script removed - Noscript Ad: \9 -->\r\n\2"