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....

Wolf War
  • 1,503
  • 1
  • 15
  • 28
  • 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. – Rob W Jun 25 '15 at 14:37
  • @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) somehow – Wolf War Jun 25 '15 at 14:47
  • @RobW, It could be data:text/html too. Chrome should allow us to access it. – Pacerier Aug 06 '17 at 07:15
  • Hooking https://stackoverflow.com/q/15461142/632951 and https://stackoverflow.com/q/37093152/632951 – Pacerier Aug 06 '17 at 07:39
  • @Pacerier 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 https://bugs.chromium.org/p/chromium/issues/detail?id=55084#c24 – Rob W Aug 06 '17 at 08:10

2 Answers2

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.

Xan
  • 74,770
  • 16
  • 179
  • 206
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.

Paul Irish
  • 47,354
  • 22
  • 98
  • 132