0

In this case, lets take YouTube as an example:

The below code, I believe, is scripted to append a string to search_query=, but it gets appended to &page= as well.

enter image description here

if (oSession.uriContains("www.youtube.com/results?search_query=")) 
{
  var str = oSession.fullUrl;
  var sAppend = "+test1+test2+test3";
  if (oSession.fullUrl.indexOf(sAppend, str.length - sAppend.length) < 0)
  {
     oSession.fullUrl = str + sAppend;
  }
}

Thank you in advance.

nasekt
  • 15
  • 7
  • Is this really Javascript? The code in your image looks like Java. Javascript doesn't have `public static function` syntax. – Barmar Sep 14 '14 at 04:34
  • The code is JScript .NET, which is basically a .NET version of Javascript.Regardless of language, Anyone with `appending` type of skill can answers my question. – nasekt Sep 14 '14 at 04:42
  • I don't see any way that that could be inserting the `+test1+test2+test3` in the middle of the URL. It should only append it. Something else must be doing the second append. – Barmar Sep 14 '14 at 04:44

1 Answers1

0

You can try this code:

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;
  }
}
Jatinder Kumar
  • 503
  • 6
  • 17
  • Can you please clarify in question, what you want to achieve. – Jatinder Kumar Sep 14 '14 at 05:41
  • My Goal:Append `+test1+test2+test3` to query,then before data reaches the web browser **hide** the `+test1+test2+test3` present in the search box. Example http://i.imgur.com/sfBeiRR.png – nasekt Sep 14 '14 at 06:17
  • As you can see, using **oSession.utilReplaceInResponse**, I tried to replace `+test1+test2+test3` with `blank`, but Failed. Is there any alternative method? Thank you – nasekt Sep 14 '14 at 06:23
  • Sorry, it was my fault, semicolon was missing.Thank you very much for helping me. – nasekt Sep 15 '14 at 16:39