My Goal:Append +test1+test2+test3 to query, then before data reaches the client's web browser replace +test1+test2+test3 with an empty string.
To append string to query, I used this code
static function OnBeforeRequest(oSession: Session) {
if (oSession.uriContains("www.youtube.com/results?search_query="))
{
var str = oSession.fullUrl;
var sAppend = "+test1+test2+test3";
if (!oSession.uriContains(sAppend))
{
oSession.fullUrl = str + sAppend;
}
}
Everything worked fine, but the problem started after I added this code
static function OnBeforeResponse(oSession: Session) {
if (oSession.HostnameIs("www.youtube.com") && oSession.oResponse.headers.ExistsAndContains("Content-Type","text/html")){
oSession.utilDecodeResponse();
oSession.utilReplaceInResponse('+test1+test2+test3','');
Instead of appending to search_query=, it gets appended to &page=
I'm pretty sure oSession.utilReplaceInResponse is responsible for the problem.I really need help.
Thank you.
To append string to query, I used this code
static function OnBeforeRequest(oSession: Session) {
if (oSession.uriContains("www.youtube.com/results?search_query="))
{
var str = oSession.fullUrl;
var sAppend = "+test1+test2+test3";
if (!oSession.uriContains(sAppend))
{
oSession.fullUrl = str + sAppend;
}
}
Everything worked fine, but the problem started after I added this code
static function OnBeforeResponse(oSession: Session) {
if (oSession.HostnameIs("www.youtube.com") && oSession.oResponse.headers.ExistsAndContains("Content-Type","text/html")){
oSession.utilDecodeResponse();
oSession.utilReplaceInResponse('+test1+test2+test3','');
Instead of appending to search_query=, it gets appended to &page=
I'm pretty sure oSession.utilReplaceInResponse is responsible for the problem.I really need help.
Thank you.