chrome.tabs.executeScript into dataURI tab
Asked Answered
E

2

3

Question is very simple (to ask)
Is there any way to inject script into tab containing only image
and have URL in form of:
data:image/png;base64,iVBORw0K....

console gives me error:
Cannot access contents of url "data:image/png;base64,iVBORw0K....

Ebenezer answered 25/6, 2015 at 13:12 Comment(5)
No you cannot, but since data:-URIs are generally static, you could replace the data URI with another data:-URI or extension page plus your desired functionality.Adjacent
@RobW yea, I have extension page, but I wanted to have, sort of speaking "loose end" not hooked to extension views in any form and to keep my BG page asleep. If I open it with dedicated HTML file, and deal with heavy data (image dataURIs) it consumes memory a lot. It looks much nicer to have styled HTML preview, and I was thinking to inject that part independently. I'll try nesting dataURIs (code +image data) somehowEbenezer
@RobW, It could be data:text/html too. Chrome should allow us to access it.Prepay
Hooking https://mcmap.net/q/1114953/-chrome-extension-permissions-to-manipulate-content-of-data-uris/632951 and https://mcmap.net/q/1160178/-unchecked-runtime-lasterror-while-running-tabs-executescript-cannot-access-contents-of-url-quot-data-text-html-chromewebdata-quot/632951Prepay
@Prepay Note that the folks at Chromium are receptive to supporting content scripts in data:-URLs, it's just that nobody is working on implementing it, see comments 24 - 27 at bugs.chromium.org/p/chromium/issues/detail?id=55084#c24Adjacent
I
1

Looks like the answer is "no". data: URIs are not supported by permissions.

Even "activeTab" or "<all_urls>" permission does not grant the required rights.

A glance on the Chromium bug tracker did not find an existing feature request for that - you may try your luck.

Illusionary answered 25/6, 2015 at 13:57 Comment(0)
O
0

Agreeing with Xan, it's a chromium bug that extensions cannot work on data URIs.

A fix is going in that will rectify this, hopefully landing in Chrome 66.

Overhead answered 15/2, 2018 at 18:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.