Last active
November 4, 2020 16:17
-
-
Save skaveesh/204379557f83ed4d246ac43bc9f26277 to your computer and use it in GitHub Desktop.
Binary trade purchase in one click
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name One Click Purchase Binary | |
// @namespace http://tampermonkey.net/ | |
// @version 1.2 | |
// @description binary trade purchase in one click | |
// @author You | |
// @match https://webtrader.binary.com/* | |
// @grant none | |
// @author Samintha Kaveesh | |
// @require https://code.jquery.com/jquery-1.12.4.min.js | |
// ==/UserScript== | |
//////////////////////below code is waitForKeyElements | |
//////////////////////detects and handles AJAXed content. | |
//////////////////////https://gist.githubusercontent.com/BrockA/2625891/raw/9c97aa67ff9c5d56be34a55ad6c18a314e5eb548/waitForKeyElements.js | |
function waitForKeyElements ( selectorTxt, actionFunction, bWaitOnce, iframeSelector ) { var targetNodes, btargetsFound; if (typeof iframeSelector == "undefined") targetNodes = $(selectorTxt); else targetNodes = $(iframeSelector).contents () .find (selectorTxt); if (targetNodes && targetNodes.length > 0) { btargetsFound = true; targetNodes.each ( function () { var jThis = $(this); var alreadyFound = jThis.data ('alreadyFound') || false; if (!alreadyFound) { var cancelFound = actionFunction (jThis); if (cancelFound) btargetsFound = false; else jThis.data ('alreadyFound', true); } } ); } else { btargetsFound = false; } var controlObj = waitForKeyElements.controlObj || {}; var controlKey = selectorTxt.replace (/[^\w]/g, "_"); var timeControl = controlObj [controlKey]; if (btargetsFound && bWaitOnce && timeControl) { clearInterval (timeControl); delete controlObj [controlKey]; } else { if ( ! timeControl) { timeControl = setInterval ( function () { waitForKeyElements ( selectorTxt, actionFunction, bWaitOnce, iframeSelector ); }, 300 ); controlObj [controlKey] = timeControl; } } waitForKeyElements.controlObj = controlObj; } | |
var executedOnce = false; | |
$(document).ready(function() { | |
//waiting for ajax to (when document load vB_Editor_QR_iframe) | |
waitForKeyElements (".ui-dialog", loadElementsAfterLoadingDoc); | |
function loadElementsAfterLoadingDoc(){ | |
(function(){ | |
var clickEvent = new MouseEvent("click", { | |
"view": window, | |
"bubbles": true, | |
"cancelable": false | |
}); | |
if(!executedOnce){ | |
'use strict'; | |
var parentDivElement = document.getElementById("nav-menu"); | |
var purchaseInOneClickButton = document.createElement("button"); | |
purchaseInOneClickButton.innerHTML = "Purchase in One Click"; | |
purchaseInOneClickButton.addEventListener("click", function() { | |
var purchaseButtons = document.getElementsByTagName("button"); | |
var purchaseButtonsArr = []; | |
for(var i=0; i<purchaseButtons.length; i++){ | |
if(purchaseButtons[i].innerHTML.localeCompare("Purchase") === 0){ | |
purchaseButtonsArr.push(purchaseButtons[i]); | |
} | |
} | |
for(var j=0; j<purchaseButtonsArr.length;j++){ | |
purchaseButtonsArr[j].dispatchEvent(clickEvent); | |
} | |
}); | |
parentDivElement.appendChild(purchaseInOneClickButton); | |
executedOnce = true; | |
} | |
})(); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment