Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to override variable parameter loaded from another script

I have a script that loads the code dynamically. It is kind of a search engine. When I press a search button, the action gets triggered and a new page opens with many parameters.

I want to override one of the parameters generated with the script in the new URL. JS code is quite big and hard to read, but I have found the important part in the Firebug DOM editor.

This is the pattern of the URL generated when you perform the search:

http://www.example.com/...?ParameterOne=123&ParameterTwo=Two&ThisParameter=Sth&ParameterFour=Four...

What I want to edit is "ThisParameter" and change its value. This is the part edited in the DOM that does what I want:

Foobar = {
_options: [],
...
var options = {"ParameterOne":123,"ParameterTwo":"Two","ThisParameter":"ABC","ParameterFour":Four,...}
...

And this is the output of "ThisParameter" when you choose "Copy path" in Firebug's DOM tab:

_options[0].ThisParameter

I am wondering it this is possible at all. What makes me think that it is, is the fact that I can change this parameter in Firebug and it works perfectly. So, if Firebug can edit it, there should be a way to influence it with another script.

Looking forward to any suggestions, thank you in advance!

like image 955
take2 Avatar asked Oct 23 '12 18:10

take2


1 Answers

Since you cannot edit the dynamic script you have the following options:

  1. You have to try to give the script the correct input and hope it uses your value.
  2. Add a script to the results page which will read the url and arguments, change it and redirect, as we discussed here. (If you put everything in functions it should not conflict with the dynamic script if the functions are uniquely named.)

You could try adding something like this jQuery code to the page with the search button:

$('input[name=search_button_name]').click(function(e) {
    e.preventDefault();
    var form_search = $('#search_form_id');
    $('<input>').attr({
        type: 'hidden',
        name: 'ThisParameter',
        value: 'SomethingElse'
     }).appendTo(form_search);
     f.submit();
});
like image 109
Stefan Avatar answered Nov 13 '22 23:11

Stefan