I have a working Chrome Extension that opens a new tab and navigates to the specified URL. I'm looking to see if I can somehow have that new tab be opened with developer tools open as well. Is this possible?
chrome.tabs.create({
active: true,
url: "http://www.google.com"
}, createTabListener);
Unfortunately, it is not possible at the moment. You can vote for this issue to support the feature request: https://code.google.com/p/chromium/issues/detail?id=410958
Related
When I run my tests, the Developer Tools panel is automatically open. Can I close it using Playwright? I don't need to see it.
If you are using chromium.launch you can disable DevTools from showing with the following config.
const browser = await chromium.launch({
devtools: false
});
More information in the Playwright documentation: https://playwright.dev/docs/api/class-browsertype#browser-type-launch-option-devtools
I have a Chrome Extension Page Action that I wish that users can run both in incognito mode and in regular mode.
The page action open new tabs with:
window.open(url);
I need that the Page Icon opens a new incognito tab if in incognito mode and a regular tab in regular mode. Therefore, I added the following sentence in the manifest:
"incognito": "split",
In the background.js file of the extension, the following code enables the page action:
chrome.runtime.onInstalled.addListener(function() {
// Replace all rules ...
chrome.declarativeContent.onPageChanged.removeRules(undefined, function() {
// With a new rule ...
chrome.declarativeContent.onPageChanged.addRules([
{
conditions: [
new chrome.declarativeContent.PageStateMatcher({
pageUrl: { urlMatches: '<a_url_pattern>' },
})
],
// And shows the extension's page action.
actions: [ new chrome.declarativeContent.ShowPageAction() ]
}
]);
});
});
The page action works fine (the page icon is enabled both in incognito and in non-incognito mode) if I load the extension locally. However, after publishing the extension in the Web Store, the page icon only is enabled in non-incognito mode.
Why do I have this difference in behavior in incognito mode between loading locally or loading the published version from the web store?
BTW, before adding "incognito", "split" in the manifest file, the page icon was enabled both in incognito mode and in normal node in the previous published extension, so it seems that "incognito", "split", which was the only line changed in the extension update has something to do with it.
UPDATE: After further investigation, the mismatch in behavior was not caused by the origin of the extension (i.e. load unpacked vs. web source), but depends on if there is an incognito window open when you click Allow in incognito in chrome://extensions.
It seems that, in split mode, if there is an incognito window open when you click Allow in incognito, the onInstalled listener will be fired both for incognito and non-incognito contexts. However, if there is no incognito window open when you click Allow in incognito, then the onInstalled listener will be only fired in the non-incognito context, so the page action icon will not be enabled in incognito context.
This seems to be a Chrome bug. A workaround for this bug is described in the answer to this SO question.
so I am trying to make a google chrome extension and I want it to open when you open a new tab. Kind of like muz.li. Basically, when you press ctrl+t to open a new tab instead of showing google, it shows my extension.
Thanks!
Simple add the code below to open the extension when a new tab is opened, you don't need a background js or html file. It is in the manifest.json file:
"chrome_url_overrides": {
"newtab": "page.html"
},
I suggest to use the chrome.tabs.onCreated event to detect when someone opens up a new tab.
https://developer.chrome.com/extensions/tabs#event-onCreated
I'm developing a chrome extension and I want to automatically refresh the active tab after a code change
I got gulp-open to work so I don't need to navigate to chrome://extensions anymore and manually click "reload"
now only the active tab refresh remains
I've tried gulp-livereload but couldn't get it to work for developing a chrome extension
any ideas how to approach this?
Could you post the code of your chrome extension? Without much info, I hope this is helpful. You can inject the code below to refresh the page after the chrome extension is reloaded:
chrome.tabs.query({
active: true, // Select active tabs
lastFocusedWindow: true // In the current window
}, function(tabs) {
// Since there can only be one active tab in one active window,
// the array has only one element
var tab = tabs[0];
// Javascript to reload the page
var code = 'window.location.reload();';
// Execute the code for the current tab
chrome.tabs.executeScript(tab.id, {code: code});
});
Is this still valid?
"app": {
"launch": {
"local_path": "window.html",
"container": "tab"
}
},
I'm using Chrome v46 and it works but I'd like to be sure it is not a bug.
I cannot see anything like this in the manifest file reference
Your manifest snippet (containing app.launch.local_path) describes a legacy packaged app. These are deprecated and not officially supported any more.
If you want to have an icon in the app launcher, then you need to create a Chrome app (if you want to host the content in the package) or a hosted app (if you want to host the content online).
If you don't want to create an app, but an extension, then you could use a browser action button to add a button to the toolbar, and then open a page in a new tab using chrome.tabs.create. Or, if your actual goal is replacing the new tab page, use chrome_url_overrides to override newtab.