Chrome extension can't get access to chrome://extension-icon - google-chrome

I'm trying to list other extensions from my Chrome extension, and show their icons.
Another extension (Zenmate VPN) shows other's icons easily. I figured out that it has management permission in it's manifest.
I add "management" to optional_permissions and ask user to enable it after a click.
After that, I can list extensions, but the icons are still unaccessible in the page.
When I add management to permissions section, everything works fine. The problem is that we don't want to add this permission there, because Chrome will disable the extension by default if the updated version asks for more permisssions.
Is there a way to somehow refresh permissions in a page, in order to make icon URLs work (chrome://extension-icon/*), like they work in ZenMate?

If you already have chrome://favicon permission you can use it to display an extension favicon:
<img src="chrome://favicon/chrome-extension://igiofjhpmpihnifddep‌​npngfjhkfenbp/">
In case you didn't have chrome://favicon permission initially, try adding it in optional_permissions. If it won't work, try adding to permissions but first test if it'll disable your extension on update.
Other icon sizes may be specified (in the absence of an actual big icon the default 16x16px is scaled):
Retina 2x DPI: chrome://favicon/size/16#2x/chrome-extension://.......
48px: chrome://favicon/size/48/chrome-extension://.......

I checked if I could go with wOxxOm's answer, and mostly extensions did not have bigger favicons, nor I can request chrome://favicon/* permission: Chrome throws an exeption:
Unchecked runtime.lastError while running permissions.request: 'chrome://favicon/*' is not a recognized permission.
So I found a simple and robust solution: I just close the current tab and create a new one:
permissionsAchieved = function(allowed) {
chrome.tabs.create({ url: "<write current url here>" });
window.close();
},
Done. In the newly opened tab, the icon is shown correctly.
But thanks for a suggestion!

Related

changing the default private browsing page

Is there a way to change the default page that loads up when entering private browsing/incognito? I would like to either replace the page or, preferably, add text to the current one.Can this be done programmatically(not from a plugin/addon/extension)? if not can this be done with a plugin of some sort?the best I could find is an addon for chrome that requires specifically toggling permissions to run in private and it will only work on remote pages and not local pages, which does not fit my needs
1.You must Use chrome-pak-customizer To unpack resources.pak
https://github.com/myfreeer/chrome-pak-customizer/releases
like
pak_mingw64.exe -u resources.pak c:\dir2
2.After this, you must change 12002.html
Content of 12002.html
$i18n{incognitoTabHeading}
$i18n{incognitoTabDescription} {$i18n{learnMore}}
$i18nRaw{incognitoTabFeatures}
$i18nRaw{incognitoTabWarning}
{$i18n{learnMore}}
3.Pack Folder
pak_mingw64.exe -p c:\dir2\pak_index.ini c:\temp\res1.pak
4.Replace resources.pak with Your own in chrome folder!
Voila!
I think this cannot be performed without an extension. I've tried this one: New tab redirect. In the options of the extension you can set the url you need to redirect to (even a local url works) and enable the extension to work in incognito mode in the chrome options. Now when you open incognito mode it loads the url I've set.
Create a shortcut to chrome on desktop.
Right click, select Properties
In Target label under Shortcut, after "C:..\Google\Chrome\Application\chrome.exe" just add -INCOGNITO WWW.GOOGLE.COM without quotes and click Apply.
You may add link to any page you wish to open in incognito instead of WWW.GOOGLE.COM

Changing Chrome extension site access has no effect

Chrome extensions have a "Details" page (for example, here's Adblock's). On this page you can change the permissions of the extension to be one of: On click, On specific sites, or On all sites. These options determine whether the extension runs all the time on every site or only when you want them to.
This extension, however, does not change behavior when I modify the permissions from its Details page. Why is this the case? Here's their source code on Github.
I noticed that they use a persistent background page. Would that cause the issue?
Thanks in advance.
The correct answer as stated in the comments:
[the extension] doesn't actually run on sites other than Reddit. It just takes an URL of a tab and runs it through Reddit.
This means that changing the permissions in the Details page doesn't affect anything.

How to Make my Chrome Homepage an Extension

Here is an interesting one. We want to use the extension "Kiosk" for our computers to lock down the browser to only allow our website to play but we need it to auto load to that.
We have another security layer that will lock down the computer on boot up, which we can assign a application to run (chrome in this case). All we need to do is make sure that when Chrome is loaded it boots directly into the "Kiosk" Extension.
We have the extension ID, but we cannot get chrome to assign the extension as the home page.
Has anyone done something like this in the past?
You can add "chrome_url_overrides" inside your manifest.json to override
Chromes new tab and some other Chrome pages.
For example:
"chrome_url_overrides": {
"newtab": "new-tab.html"
}
You can also redirect to any other site within your HTML file.
You can read about it more here.
Edit:
Like I said in the comments you can also create a .bat file to run on startup that is going to open your kiosk app.
The code inside your .bat file can look like this:
start chrome.exe --app-id=afhcomalholahplbjhnmahkoekoijban
You can also add more parameters if you require any more settings when starting chrome.exe.

Is there a way to stop Google Chrome from showing most visited sites on a blank tab?

Whenever I open a new tab in Google Chrome I see the Google search bar plus 8 thumbnails of recently visited (or most visited) sites. I never click on the thumbnails and find them to be annoying. Is there anyway to disable this in Chrome?
I can think of a hacky workaround like creating a blank page someplace and setting that to be the new tab page, but there must be a better way. Any ideas?
Since nobody answered I thought I would post and answer to my question:
Use the Empty New Tab Page extension for a new blank tab instead of the default new tab.
There are also some redirect extensions such as Momentum, which loads a different full screen image each day.
type chrome://flags then Disable "Top Sites from Site Engagement"
Chrome allows extensions to run on chrome:// urls so one such possible future solution is if AdBlock explicitly requests the permission to run on chrome://newtab then you can just block the div with id most-visited. But currently AdBlock does not request this permission.
You could edit the manifest of AdBlock manually to include this permission or suggest it as a future feature.
The default new tap page's url is chrome-search://local-ntp/local-ntp.html. You can press F12 to check it. It's a local resource located in
C:\Program Files (x86)\Google\Chrome\Application\{Version}\resources.pak
or
C:\Users\%username%\AppData\Local\Google\Chrome\Application\{Version}\resources.pak
Open it with a HEX editor, search text
cur.style.opacity = 1.0
, and replace it with
cur.style.opacity = 0.0
Tested on Chrome 77.0.3865.90 .

Does content script have access to newtab page?

Updated
Thanks #kofifus for the info, Chrome as of 61 explicitly forbids content scripts on its default new tab page
Previous
Say I have the following sample extension, it will output test in console.
manifest.json
{
"name": "Test",
"version": "1.0",
"manifest_version": 2,
"content_scripts": [
{
"matches": [
"<all_urls>"
],
"js": [
"content.js"
]
}
]
}
content.js
console.log('test');
Will above extension work well in chrome://newtab page?
Some helpful info:
I know by default chrome extension can't access to chrome:// pages, and we could change this behavior through chrome://flags/#extensions-on-chrome-urls
chrome://newtab in fact is a url like https://www.google.co.jp/_/chrome/newtab?espv=2&ie=UTF-8, so it shouldn't be blocked by above restriction.
There are many mouse gestures extension available, like crxMouse, they work well on chrome://newtab page
There are also some voices saying it's not allowed to inject content scripts in chrome://newtab, for example, #Xan's comments below this answer
and this author's case
So it looks weird as its different behavior across different devices( or settings?). Is there any official statements about whether content scripts can run in chrome://newtab pages? Or is there a setting we could change this behavior?
Chrome as of 61 explicitly forbids content scripts on its default new tab page
Q: Is there any official statements about whether content scripts can run in chrome://newtab pages?
A: Not really, but Google's documentation states that:
Host permissions and content script matching are based on a set of URLs defined by match patterns. A match pattern is essentially a URL that begins with a permitted scheme (http, https, file, or ftp, and that can contain '*' characters. The special pattern matches any URL that starts with a permitted scheme.
chrome://newtab only redirects the user to whatever url is set as the new tab page. Usually it will redirect the user to https://<your local google domain>/_/chrome/newtab(a permitted match pattern). But if another extension sets the new tab page to customNewTab.html, then chrome://newtab will redirect the user to chrome-extension://chrome-id/customNewTab.html, and any other extension's content scripts will not be able to run on the new tab.
This SA question also confirms this. If you try adding "exclude_matches": ["*://*/_/chrome/newtab*"], to your manifest, the content script will stop working on the new tab page.
Q: Is there a setting that could change this behavior?
None beside an override page set by another extension. (Note that themes only change the appearance of the new tab, and won't override the new tab url)
Q: Will above extension work well in chrome://newtab page?
A: yes, unless that tab was overriden by another extension.
I have a 30,000 user extension called Screen Shader on the extension store with a huge variety of different chrome versions and a few different browsers, and so far no one has complained about it not working on the new tab page, when they complain a lot about other things.
I'm not too sure why other people think it shouldn't work on the new tab page, but hopefully this answered all the questions you were having.
On a sidenote: Keypress problems with the new tab page
On his blogpost at http://www.toptip.ca/2010/01/google-chrome-content-script.html the developer of "Boss Key and Button" complains about issues with running a content script in the new tab page. His extension minimizes all chrome windows and opens the one you are currently on in a new tab whenever you press F9. He thought the content script didn't work on the new tab page because whenever he used his shortcut in the new tab page, nothing happened. He failed to realize that the reason it wasn't working on the new tab page was because chrome redirects any keypresses to the browser bar so his content script could not capture the keypress.
Try using his extension and pressing F9 on a random page. All chrome windows will be minimized. go back to that random page, and click in the address bar and try pressing F9. This time nothing will happen.