“Error: Missing host permission for the tab” on view-source: URLs

隐身守侯 提交于 2019-12-06 05:00:36

问题


I rewrote my extension to WebExtensions for Firefox and Google Chrome, and it works fine for HTTP/HTTPS. However, it no longer works on URLs with the view-source: scheme. (These URLs are the HTML source code of web pages shown by CTRL+U.)

Firefox 57 gives this error

Error: Missing host permission for the tab

Google Chrome 62 does apparently nothing.

There is no documentation about the view-source scheme. Is there a way to enable the extension for view-source?


回答1:


I haven't dabbled too much in extensions but since the error involves Host permissions in firefox, check the Host permissions:

In Firefox, from version 56 onwards, extensions automatically get host permissions for their own origin, which is of the form:

moz-extension://60a20a9b-1ad4-af49-9b6c-c64c98c37920/
where 60a20a9b-1ad4-af49-9b6c-c64c98c37920 is the extension's internal ID. The extension can get this URL programmatically by

calling extension.getURL():

browser.extension.getURL("");
// moz-extension://60a20a9b-1ad4-af49-9b6c-c64c98c37920/


来源:https://stackoverflow.com/questions/47503841/error-missing-host-permission-for-the-tab-on-view-source-urls

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!