Attach to Chrome instance and run JavaScript in a tab - javascript

I'd like to connect to an existing instance of Google Chrome and run some JavaScript to find a specific tab and execute some code in it.
I remember reading something about how to do this a long time ago. Can anybody offer any guidance?
Edit: I've done this before using Firefox, and I just remembered I used the MozRepl extension there.

After remembering more about how I did this in the past with Firefox, it looks like the ChromeRepl extension may be the way to go here.

Related

How to best Javascript code trace in browsers?

When I right-click an element in Internet Explorer or Chrome, it takes me to the code, but if there's Javascript referencing an object or function, I want to be able to easily click it some way to just bring me to that object or function where it's instantiated in the code. Right now I have to copy the code and search for it in another tab or section, and it's difficult in IE.
Is there some shortcut (like Ctrl+click in an IDE like Eclipse or PHPStorm) or some feature I'm missing that does this, or is there a plugin or something I can install that would do this or something like it (at least easier than what I have to do now)?
I've been looking around for hours and have tried a few things but it seems like a lost cause.
When I right-click an element in Internet Explorer or Chrome, it takes me to the code
I don't understand what you mean. What code?
but if there's Javascript referencing an object or function, I want to be able to easily click it some way to just bring me to that object or function where it's instantiated in the code.
F12 is not an IDE. If you want to find a declaration or reference, use your IDE.
Is there some shortcut (like Ctrl+click in an IDE like Eclipse or PHPStorm) or some feature I'm missing that does this, or is there a plugin or something I can install that would do this or something like it (at least easier than what I have to do now)?
Not that I'm aware of.
The title of your questions is
How to best Javascript code trace in browsers?
You can trace code to your heart's content in browsers. That's an entirely different issue from tracking down where functions or objects are declared.

How to check if Javascript is activated from Firefox extension?

I haven't found any info on that. I basically need to know from a Firefox extension if the browser has javascript enabled. Is that possible?
I am totally new to programming FF extensions -- actually this is my first one and among the requirements is this one I haven't been able to figure out.
Via #ChristianSonne: You could try
require("preferences-service").get("javascript.enabled")
in Jetpack-style addons.

Create a Addon to modify JavaScript Data before executed on Firefox

i want to create an addon for firefox, that should check every JavaScript on a loading page. And if there is a Code, which is not allowed it should be blocked or modiefied (it is a part of XSS Protection).
But i don't know, how to implement this.
I tried to create an http-on-modify-request observer and so i have an access to the scripts. But how can i modify them before Firefox execute it?
My second trial was to create an addon like the Flashblock addon.
So i made a CSS-file and bind the script tags to a xml-file.
In the xml file i create a placeholder and replace the javascript.
When i start a page and look into DOM-Inspector it works fine... there are div-tags instead of javascript tags.
The Problem is, that Firefox still executed the original javascripts and so my trial failed.
Have anybody some tips for me?
ps: sry, for my english, but english is not my native language
I think you're looking for nsITraceableChannel:
http://www.softwareishard.com/blog/firebug/nsitraceablechannel-intercept-http-traffic/

How Greasemonkey for IE runs a user java script?

Can anybody explain me, How greasemonkey runs a user script?
I am looking forward to know the technical details i.e, How and where the script is read and run, at gresemonkey or on the browser?How the interaction between greasemonkey and browser takes place?
I know how to install the scripts.
Basically I am using Greasemonkey for IE and IE8.
Thank you
The source code is available on github and Mozilla have extensive documentation on writing add-ons.
… ah, you're talking about "Greasemonkey for IE" and not "Greasemonkey". The source code is still available, just in a different place, was still available when this question was asked but it looks like the project has since died. I bet MSDN will have equivalent docs somewhere.

Opening Outlook by JavaScript in Firefox

I want to open Outlook from Javascript, it's for an internal application, nothing that will ever hit the web. The customer is using IE and Firefox and Outlook will be installed, security is not an issue.
"mailto:" just isn't sufficient in this case, since the requirement is that I need to attach a file to the mail, it seems that this cannot be done by using "mailto:" (found some old-ish forum entries, but nothing of what I tried worked and it seems that the mailto URL scheme doesn't officially support it).
But, in IE I can use ActiveX:
var outlookApp = new ActiveXObject("Outlook.Application");
and then I can mess around with it, add a body, add attachments and so on, perfect.
Is something like this possible in any way in Firefox?
What I already knew was that tiddlywiki does some extraordinary things, in that it can save itself somehow on the harddisk. So I looked at the source and found this:
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
Which, as I understand gives the Script access to the Browser API/XPConnect/XPCOM. But now I'm stuck. How would I actually open an Outlook object? Would this even be a working approach? I'm not sure. Maybe any other ideas? Any advice would be appreciated.
Update:
ok, after some reading I think I can answer one of my questions with: No, this approach won't work, since the Mozilla API that's implementing XPCOM doesn't support anything like opening an external program.
Still leaves the question: Any other ideas?
Answering my own question with this: Ignore the spec, it's a bad idea.
It could be solved with an ActiveX Plugin in Firefox, but actually it's far better to just not do something like that because of security issues, even if it is only an internal application. Some browser settings need to be changed to get something like that to work, which is risky. And finally, the spec contained a not-use-case here: "upon click of a button, open outlook to send an attached file via email". The stupid thing is, that there's actually nobody whom the employees would be allowed to send the file to, apart from other employees which can access the file in the internal network, so it's far easier (and can also be securily implemented) to just send a link to the file.

Categories

Resources