Force inspect-element using js? - javascript

Edited answer:
In most browsers, there is a function called "Inspect" or "Inspect element" that opens up the developer tools. This allows you to use many different tools, like changing the DOM, running JavaScript, finding the sources of linked files, change the CSS and other things. This tool set can be used to mess around, but also for other purposes, like cheating on online tests. That is the reason that many schools have blocked this functionality from the students. Being a avid learner and programmer, I decided that I would use other methods. I am wondering whether or not I could use JavaScript to open the Developer tools panel, even though I am guessing that JavaScript can't react with the browser, only the page. If there is a JavaScript alternate for the developer tools menu, please tell me about it. Thank you for your time, I really hope that I get question asking back. For anyone wondering, I am only really able to interact with a page through bookmarklets.

here you go
javascript:(function()%7B(function() %7Bvar x %3D document.createElement("script")%3Bx.src %3D "https%3A%2F%2Fcdn.jsdelivr.net%2Fgh%2FSnowLord7%2Fdevconsole%40master%2Fmain.js"%3Bx.onload %3D alert("Loaded Developer Console!")%3Bdocument.head.appendChild(x)%3B%7D)()%7D)()
paste into url section of bookmark and name it what you want.

If it's a custom build Chrome version and they disable or even remove the tool, then there is nothing you can do.
Chrome interface is not under control of Javascript, which is only for render. You can access (if is enabled) using hotkeys (Ctrl+Shift+J or I), F12, right click elements or access via the interface.

Try creating a bookmark and calling it 'Inspect Element'. Then assign this code to the URL part of creating the bookmark:
javascript:void(myDiv=document.createElement('div'));void(myBody=document.getElementsByTagName('body')%5B0%5D);void(myDiv.style.background='url(http://www.andybudd.com/images/layoutgrid.png)');void(myDiv.style.position='absolute');void(myDiv.style.width='100%');void(myDiv.style.height='100%');void(myDiv.style.top='0');void(myDiv.style.left='0');void(myBody.appendChild(myDiv));

Related

How can the Google Chrome DevTools Console be made fullscreen using JavaScript?

I was wondering whether it is possible to make the Google Chrome DevTools Console go fullscreen using JavaScript?
The Google Chrome console doesn't include any Javascript API's for making the window full screen (or for modifying window dimensions at all). Unfortunately, this means it is not currently possible to natively alter the size of the console (or make it go full screen) programatically.
https://developers.google.com/web/tools/chrome-devtools/console/console-reference
That said, Chrome dev tools is built to be extensible and anything is possible. If you wish to create your own Chrome plugin to interact with the console window and make it full screen programatically, you very likely can.
The obvious downside to this method is that you'd have to ask a user to install your custom plugin in order to use this functionality. That may not pose a problem depending on your use-case, but it's something to be aware of.
https://developer.chrome.com/devtools/docs/integrating

Regarding chrome fullscreen message disable

I need to disable fullscreen message ("you've gone fullscreen") coming on the top when chrome fullscreen mode is activated .
i need to do it through javascript . but it's one of the default functionality of chrome.
can any one help me out ?
It's not possible. As you pointed you it's one of the default functionality of chrome.
and I agree with the comment by mic You can't it's there for security
That message is, if you it can be disabled at all, likely a user preference. I have had my fair share of changing that kind of things for a custom "layer" over windows with an integrated browser and I can tell you it's impossible with javascript without some listener app. We created a C# listener app for that kind of thing that keeps checking a certain text file. We made javascript edit the text file and then let C# work it's hacking magic in some of the user's settings.
You could take a look at Chromium, the stripped down version of Chrome, if that would be of any help ;)
ps: To all the people going mental over changing user settings like that, our customers were old people that were unable to use a computer, and our application's purpose was to do as much as possible for them.
You cannot possibly do that as suggested by these links.
https://superuser.com/questions/398945/disable-the-youve-gone-full-screen-notification-in-chrome
https://groups.google.com/forum/#!topic/chromebook-central/h1crbhOy-7U
On the other note, why exactly would you want to do that?

How can I quickly see parsing errors in my chrome extension content script?

I can use chrome's "inspect element" feature to view and debug my javascript, but only if it has successfully loaded. If the script has a parsing error then it doesn't load and isn't shown via "inspect element".
How can I get chrome to show me its attempt to parse my script and a list of errors it has encountered?
I'm a newb to both chrome extensions and javascript, so apologies if I'm missing something obvious.
In the toolbar at the top of the Web Inspector (the window/pane that pops up when you "Inspect Element") click on the right-most button/tab, "Console," as seen here:
Not only will this show you all of the errors the page generates (JavaScript and others), it's also a full JavaScript REPL so you can interact with the page by entering any JavaScript you want.
Jordan has the right answer (should have seen that, I knew it was a newb question!), but while I was searching I also came across JSLint, which is quite useful. It's stricter than the chrome execution engine, so it generates a bunch of warnings you may not need to worry about, but still handy.

Is it possible to get browser dev tools for a specific frame?

If I'm doing Facebook application development I often find myself wanting run JavaScript in the iframe where my page is embedded, which is fairly cumbersome. It would also be nice (though my main priority is just being to on the fly run some javascript) if there was a way to run something similar to the chrome dev tools or firebug specifically on that one frame.
Do I have any options for debugging in a single frame?
In Firebug it's possible by using the cd() function. E.g.: cd(window.parent.frames[1])
I ended up embedding Firebug lite inside of the iframe for superusers, which I think I should be doing in the first place so our designer can get some feedback on the iPad and things.
I also noticed that there is a dropdown (or I guess drop-up in this case) menu in the chrome-dev channel for specifying which frame you are working in, similar to the cd() command styrr mentioned.

How to modify javascript code at run time?

Is there a way to modify JavaScript code while debugging? Visual Studio has "Edit and Continue", and similar hot swapping of code can be done in Java and other languages. Can this be done with JavaScript, and if so, how?
Chrome, Safari, and some other WebKit-based browsers contain a feature in the Web Inspector known as Live Edit. If you go to the Scripts panel and are stopped on a breakpoint (or maybe even if not stopped on a breakpoint — I'm not sure), you can double click on a line and start editing that line. The changes you make will take effect on the script.
With Chrome Developer tools, this is super easy.
Just pop open inspector, click on the scripts tab, select which one you want from the dropdown menu and then you are free to edit the script and add in breakpoints. If you refresh the page, your breakpoints will stay there.
If you watch this talk but Paul Irish, he shows how you can edit a script on the fly
http://paulirish.com/2011/a-re-introduction-to-the-chrome-developer-tools/
also good:
http://blip.tv/jsconf/jsconf2011-paul-irish-5382827
If you're talking about while debugging, it's very easy to modify the running code. In your debugging console, you can enter in Javascript expressions and it will run in the context of the window, which contains all the objects and functions of your code, so you can swap them out by redefining them.
Because JavaScript can modify the DOM the you essentially have to change the JavaScript file, save it and reload. For me, I like IE so I run the webpage in a browser NOT IN DEBUG mode. Then you can change the script files, SAVE them. switch back to the browser and reload (F5) to see your changes. Supposedly IE 11 has this ability (probably like Chrome which is essentially what I am doing, changing saving reloading from what I can tell) but I can't get it to find, let alone open a js file. Super poor UI. I'm guessing the browser to open the file icon is but it is always grayed out.

Categories