Skip to content

Instantly share code, notes, and snippets.

@deyvin
Created February 29, 2012 13:19
Show Gist options
  • Select an option

  • Save deyvin/1940786 to your computer and use it in GitHub Desktop.

Select an option

Save deyvin/1940786 to your computer and use it in GitHub Desktop.
Inspect Element With javaScript
function inspect(obj, maxLevels, level)
{
var str = '', type, msg;
// Start Input Validations
// Don't touch, we start iterating at level zero
if(level == null) level = 0;
// At least you want to show the first level
if(maxLevels == null) maxLevels = 1;
if(maxLevels < 1)
return '<font color="red">Error: Levels number must be > 0</font>';
// We start with a non null object
if(obj == null)
return '<font color="red">Error: Object <b>NULL</b></font>';
// End Input Validations
// Each Iteration must be indented
str += '<ul>';
// Start iterations for all objects in obj
for(property in obj)
{
try
{
// Show "property" and "type property"
type = typeof(obj[property]);
str += '<li>(' + type + ') ' + property +
( (obj[property]==null)?(': <b>null</b>'):('')) + '</li>';
// We keep iterating if this property is an Object, non null
// and we are inside the required number of levels
if((type == 'object') && (obj[property] != null) && (level+1 < maxLevels))
str += inspect(obj[property], maxLevels, level+1);
}
catch(err)
{
// Is there some properties in obj we can't access? Print it red.
if(typeof(err) == 'string') msg = err;
else if(err.message) msg = err.message;
else if(err.description) msg = err.description;
else msg = 'Unknown';
str += '<li><font color="red">(Error) ' + property + ': ' + msg +'</font></li>';
}
}
// Close indent
str += '</ul>';
return str;
}
/*------------------ usage ------------------------------*/
var myObject = [{title: 'foo', name: 'bar'}, {title: 'foo', name: 'bar'}]
document.write(inspect(myObject));
/* Credit: http://www.codeproject.com/Articles/24549/How-to-Inspect-a-JavaScript-Object */
@azernete
Copy link
Copy Markdown

Please send me Inspect element java script?

@harvey0906
Copy link
Copy Markdown

How to use ? First time

@Siaft468
Copy link
Copy Markdown

<script src="https://gist.github.com/deyvin/1940786.js"></script>

@Siaft468
Copy link
Copy Markdown

<script src="https://gist.github.com/deyvin/1940786.js"></script>

@53mbokentuaamirezshoghi-dot
Copy link
Copy Markdown

@samiulla610-hue
Copy link
Copy Markdown

javascript:(function(){

if(document.getElementById("skynet_panel")) return;

let panel=document.createElement("div");
panel.id="skynet_panel";
panel.style.position="fixed";
panel.style.top="120px";
panel.style.left="100px";
panel.style.width="240px";
panel.style.background="#1e3c72";
panel.style.color="#fff";
panel.style.padding="15px";
panel.style.borderRadius="10px";
panel.style.zIndex="999999";
panel.style.fontFamily="Arial";

panel.innerHTML=
"

Skynet Panel

"+
"ON"+
"OFF"+
"
Waiting
";

document.body.appendChild(panel);

let bot=null;

function getLastCandles(){

let candles=[...document.querySelectorAll("svg rect")];

if(candles.length<4) return null;

candles=candles.slice(-4);

return candles.map(c=>{
let color=c.getAttribute("fill")||"";
if(color.includes("f")) return "red";
return "green";
});

}

function runStrategy(){

let c=getLastCandles();
if(!c) return;

let [c1,c2,c3,c4]=c;

if(c1=="red" && c2=="red" && c3=="red" && c4=="green"){
let btn=document.querySelector("button[class*='buy']");
if(btn) btn.click();
document.getElementById("sky_status").innerText="BUY";
}

if(c1=="green" && c2=="green" && c3=="green" && c4=="red"){
let btn=document.querySelector("button[class*='sell']");
if(btn) btn.click();
document.getElementById("sky_status").innerText="SELL";
}

}

document.getElementById("sky_on").onclick=function(){
bot=setInterval(runStrategy,2000);
document.getElementById("sky_status").innerText="Running";
}

document.getElementById("sky_off").onclick=function(){
clearInterval(bot);
document.getElementById("sky_status").innerText="Stopped";
}

})();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment