How can I safely replace a query string with an empty string?

2 posts, 0 answers
  1. nasekt
    nasekt avatar
    40 posts
    Member since:
    Aug 2014

    Posted 14 Sep 2014 Link to this post

    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.

  2. nasekt
    nasekt avatar
    40 posts
    Member since:
    Aug 2014

    Posted 14 Sep 2014 in reply to nasekt Link to this post

    Solved it! It was a small mistake on my part.
Back to Top