I use an online forex trading website. I use this website (scroll down on the trade website to see the asset graph). I use this to trade and view forex graph. When I open the page in my browser (firefox) I want to use Greasemonkey script to automatically select or "preset" the page with the forex asset i trade in so that the page is loaded with the graph I use. For example I want to automatically select "AUD/USD".
i have tried different methods of selecting/clicking using JQuery/JS none works. I will really appreciate if someone can help with this.
I have tried each of the following to no avail:
$("#assetPlatformSelect_0_chzn a span").text("AUD/USD");
$(".chzn-search input").val("AUD/USD");
// $(".chzn-search input").focus(); //tried with and without focus
var p = jQuery.Event('keydown');
p.which = 13;
p.keyCode = 13;
$(".chzn-search input").trigger(p);
=======================================
$("#assetPlatformSelect_0 optgroup[label='currencies'] option").each(function()
{
if($(this).text() == "AUD/USD")
{
$(this).attr('selected', true);
}
else
{
$(this).attr('selected', false);
}
});
var clickNode = "";
var val2 = "assetPlatformSelect_0_chzn_o_";
$("li[id^=" + val2 + "]").each(function()
{
if($(this).text() == "AUD/USD")
{
//tried each and combination of these....
clickOnFollowButton($(this));
clickNode = $(this).attr('id');
$(this).click();
$(this).addClass('result-selected');
$(this).live('click', function () {
$(this).click();
});
}
else
$(this).removeClass('result-selected');
});
function clickOnFollowButton (jNode) {
var clickEvent = document.createEvent ('MouseEvents');
clickEvent.initEvent ('click', true, true);
jNode[0].dispatchEvent (clickEvent);
}
=======================
waitForKeyElements ("#assetPlatformSelect_0_chzn a", triggerMostButtons);
function triggerMostButtons (jNode) {
triggerMouseEvent (jNode[0], "mouseover");
triggerMouseEvent (jNode[0], "mousedown");
triggerMouseEvent (jNode[0], "click");
triggerMouseEvent (jNode[0], "mouseup");
//clickNode is the Li item to select/click
console.log($(clickNode));
triggerMostButtons2 (clickNode);
}
function triggerMostButtons2 (jNode) {
triggerMouseEvent (jNode[0], "mouseover");
triggerMouseEvent (jNode[0], "mousedown");
triggerMouseEvent (jNode[0], "click");
triggerMouseEvent (jNode[0], "mouseup");
}