Chrome extension opens multiple tabs - chrome-web-store

I built an extension for chrome, I would like to open new tab when the user click on the extension icon.
This is the code for that:
chrome.browserAction.onClicked.addListener(function(activeTab){
let newURL = "chrome://newtab";
chrome.tabs.create({ url: newURL });});
When I click the extension icon it multiple the number of new tabs(1 -> 2 -> 4...).
If I change the new URL to "google.com" its work fine, only open one tab when clicked.
Any ideas how to solve this bug?

Related

How can I make a link in firefox extension panel, to open in browser window / tab?

So I am developing my first firefox addon and I have a simple panel which contains some content and a link. When I click on the link, link is opened in the panel itself. I want to be able to open this link in firefox tab or window. I tried searching mozdev documentation but didn't find any solution.
You can either add a target attribute to your links (as _blank if you want to open a new tab every time); or intercept any click you do in the panel's document, and then send a message to your add-on code, to open a tab. Something like:
document.documentElement.addEventListener("click", event => {
let a = event.target.closest("a");
if (a && a.href) {
// replace `self` with `addon` if it's a trusted document and
// it's not a `contentScriptFile`
self.port.emit("open-link", a.href);
}
});
Then in your index.js or main.js, you'll have something like:
const tabs = require("sdk/tabs");
let panel = Panel({ /* ... your panel ... */ });
panel.port.on("open-link", uri => tabs.open(uri));

Chromecast debugging using Chrome browser

The instructions on Google site stated that for Chrome browser:
Copy the URL text starting with chrome-devtools://devtools/remote/serve_rev..., open a new tab, and paste the URL text into the URL field in Chrome.
But I could not see any of that text. (see image)
What have I missed?
Just click on Remote Debugging(AppEngine). That will open the debug console, which should contain that url. If you're on Chrome already though, there's no need to copy the url and open it in a new tab. The point of copying the url is to bring it into Chrome.
Make sure that you also enable scripts. The right most portion of the url bar should have a shield icon. Click on that to enable scripts.

How to handle new browser pop up after clicking a js button in Watir?

I am trying to using watir in ruby, I am able open a browser,
enter some values to a username/password form, but then I press enter, then I click the submit button (actually it is pressing an enter, it is easiler to code), it would pop up a new browser windows for our application, then I found I have no control to the new browser. What can I do?
In addition to my problem, the new browser window got no menubar, no toolbar, no navigation bar, thus I cannot open the IE developer toolbar to find the name of the element in the webpage in the new browser.
By the way, my app can only support IE.
I tried the attach method, but it does work:
C:/Ruby187/lib/ruby/gems/1.8/gems/watir-1.8.1/lib/watir/ie-class.rb:302:
in `attach_browser_window': Unable to locate a window with title of (?-mix:New browser title) (Watir::Exception::NoMatchingWindowFoundException)
from C:/Ruby187/lib/ruby/gems/1.8/gems/watir-1.8.1/lib/watir/ie-class.rb
:150:in `_attach_init'
from C:/Ruby187/lib/ruby/gems/1.8/gems/watir-1.8.1/lib/watir/ie-class.rb
:144:in `attach'
from test1.rb:36
Attach method is able to handle new window.
http://rdoc.info/gems/watir/1.8.1/Watir/IE.attach
for example
browser = Watir::Browser.new
browser.text_field(:id,'username').set 'username')
browser.button(:index,1).click
# popped up the new window
popup = Watir::Browser.attach(:title,'Foobar')
If you will use only the popped up window, you can overwrite browser variable instead.
You could try to authenticate like so:
examplehost.com/authentication?user=foo&password=bar
You could also try to remove "target" attribute (which is probably equal to "_blank") of that authentication form ( i'm pretty much sure you should be able to achive this with watir )
EDIT:
Also, there's this option:
ie2 = Watir::IE.attach(:title, ‘New Ie window, opened upon form submit’)
it can also attach by :url instead of :title
ok, there's possibly this solution that might work:
b = Watir::Browser.start "http://yourpage"
b.execute_script("document.getElementById('your-image-id').onClick = function() {}")
so, the idea is to get that image and overwrite it's onclick event

Is there a way to use watir to open a link in a new tab or window in firefox

I have a web application I am automating with watir. The application has a browsing page which shows thumbnails for a set of templates. Each thumbnail is a link to the template. I need to open each template in a new tab or window and take a screen shot or print a pdf of the template to verify that it opens correctly and looks correct. Then close that tab or window and return to the template browser to open the next template. I need to do this on firefox/safari chrome and IE mac and windows.
Why not open it in the same tab, take the sreenshot, then go back?
I haven't used Watir, only Selenium, but it looks like Watir has a back method as well. If not, you can probably store the URL of the page with the thumbnails and then open it directly by URL.
You can read the url of the link, store it in an variable, open a new browser window and then with ie.goto(url) you can open the link in a new browser.

FireFox button to open a specific URL with a parameter?

I'm looking for a way to write "xyz" in FireFox, and when I press a button, a URL of the form "http://www.something.com?ID=xyz" will open.
How Do I do that?
Thanks!
you can add this line as a bookmarklet in Firefox
javascript:window.location.href=document.location.href+'?ID=xyz'
When on a page, click on the bookmark and '?ID=xyz' will be appended to the URL

Resources