9
votes

I've recently been contributing to the Enhanced Steam extension and I've found that a link fetched with chrome.extension.getURL simply opens about:blank and not the link described.

I do not believe it's actually a problem with the extension, but rather a problem in chrome. The link it supplies is valid (chrome-extension://pimjhgjngccknempdnehdeaihcjbajod/options.html) and navigating directly works correctly.

I tried chrome.tabs.create, but found that I am not allowed to use it due to the script modifying pre-existing content.

Any help or work arounds would be appreciated.

2
I don't really understand what you are trying to achieve and what the problem is. I also wonder what this sentence means: "I tried chrome.tabs.create, but found that I am not allowed to use it due to the script modifying pre-existing content." - gkalpak
It is a web_accessible_resource, as described above I get the URL using chrome. The page just simply opens about:blank instead of the actual desired link. - Smashman
I'm experiencing the same problem. Links to background pages now open about:blank for some reason. - Drazen Bjelovuk
window.location.href = "chrome-extension://pimjhgjngccknempdnehdeaihcjbajod/options.html";. An anchor tag click produces the same result. - Drazen Bjelovuk

2 Answers

13
votes

I put all my required files into "web_accessible_resources", it solved my problem. See this in #4 https://bugs.chromium.org/p/chromium/issues/detail?id=310870#c4

It is Chrome's previous problem which is not secure. In build 31.0.1650.57, Chrome fixed this which is to force to put required files in "web_accessible_resources". In Chrome extension, lots of samples don't use "web_accessible_resources", those are the bugs, those samples will have this "chrome-extension:// links open about:blank" problem in build 31.0.1650.57.

Actually my chrome extension MarkView was facing this issue and I had to update its manifest.json to make it work for this Chrome update. By the way, MarkView is tool to read and write Awesome Markdown Files, it provides features including Content Outline, Sortable Tables and code block syntax highlight with line number.

2
votes

Looks like a bug in Chrome to me. If you don't have too many pages like this to change then could you try using message passing to pass the page you want to open to the background page? Then use either window.open or chrome.tabs.create within the background page. Example code shown below:

//CONTENT SCRIPT

chrome.runtime.sendMessage({greeting: "OpenPage", filename:"somepage.html", querystring:"?aValue="+someVal}, function(response) {});

Then in your Background page

//BACKGROUND PAGE

chrome.runtime.onMessage.addListener(
  function(request, sender, sendResponse) {  
 if (request.greeting == "OpenPage"){
  open_page(request.filename, request.querystring)
 }

  });


function open_page(filename, querystring){

var pageUrl = chrome.extension.getURL(filename)+querystring;

chrome.tabs.create({'url': pageUrl }, function(tab) {
  // Tab opened.
});
}