2

I'm trying to find a way to take a link from one browser and open it in another browser. This could be taking a link from a Firefox tab and opening it in Chrome, or taking a link in a Chrome Incognito window and opening it in a non-incognito Chrome window.

Here's some more detail. I have a webpage that refreshes every second, and uses javascript(via Greasemonkey/Tampermonkey) to search for certain keywords. When a keyword in my list matches one associated with a link on the page, it automatically opens that link in a new tab. If it's possible, I need to take those links to a different browser somehow, automatically.

AFAIK, something like this isn't possible with javascript due to security issues. The only two solutions I can think of are:

1: Using AutoHotKey to make a macro to copy the link, alt-tab, and paste into the other program. This is manual, I want something automatic. EDIT: I realized I can use AHK to monitor a page, but I don't know if it could be done without introducing more latency than I would like. Keeping the total time from the webpage refreshing to opening the link as low as possible is the most important thing.

2: Having some other program handle it for me. I'm not aware of any and wonder how difficult/costly it would be to roll my own or have someone make one. I'm not even sure if I could interface it with my current script.

I'm fairly certain it would be possible with number 2, although I don't know about cost or difficulty... could there be another way to accomplish this?

For reference, this is the relevant section of code that I'm currently working with. It opens any link which matches a list of keywords in a new tab. These are the links I'm trying to figure out a way to open in a different browser. It uses dynamic object names and a dynamic URL, but essentially this is just saying if the checkboxes are checked and a link matches my autoOpenList(keyword list), then open the link in a new tab.

if(jQuery.inArray(autoOpenTemp,autoOpenList) != -1  && window['autoAccept' + autoOpenTemp].checked && autoAccept_input.checked ){
    var tempURL = LINK_BASE+obj.acc_link;
    window.open(tempURL, '_blank');
}
  • I think you can [open a CLI by JavaScript][1] and just open browser from CLI. [1]: http://stackoverflow.com/questions/1880198/how-to-execute-shell-command-in-java-script – Jack Song Jun 09 '14 at 00:39
  • I've been trying to make that work, but it looks like I could only do it through ActiveX on IE, but I need to be using Chrome or Firefox. – user3720784 Jun 09 '14 at 01:40
  • I'd just like to know why you want to open it in another browser - what's wrong with the one you are using? And I know some add-ons for Firefox at least, that manage sessions for you. Aptly called "session manager." Just throwing it out there, I know it's not really what you're looking for. – Wyatt Ward Jun 09 '14 at 01:46
  • It has to do with my work. I couldn't disclose too many details, it's just that it would help me increase my productivity. I'm currently looking into using nsIProcess, but my understanding is I have to create an actual extension, a tampermonkey script doesn't have the privilege. – user3720784 Jun 09 '14 at 02:12
  • IMO, this question needs to be _a lot_ more specific to avoid being closed as "too broad". In other words, show your code and explain where you're stuck. See: http://stackoverflow.com/help/on-topic – Sparky Jun 09 '14 at 03:42
  • I'm not really stuck with any specific code, so I'm not sure what I could share. I'm asking for more general direction in how to approach a problem, which to me fits under "a practical, answerable problem that is unique to software development". I'll add a little more though. – user3720784 Jun 09 '14 at 03:45

1 Answers1

0
  1. Use Java's HttpServlet Class to create a web application. You can setup the server by Tomcat. Servlets Quick Guide.
  2. Start CLI by Java and open browser through CLI.
  3. Call the web application by url on your page.
Community
  • 1
  • 1
Jack Song
  • 478
  • 4
  • 9