Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Yes, you can do that. There's no problem with that case. You need to get current tab ID using chrome.tabs.query(), then execute JavaScript code inside that tab (ejection), and finally send runtime message from that tab (during JavaScript ejection) to the popup to substitute its HTML code with that received code. I just created a sample extension to illustrate that:</p> <p>manifest.json:</p> <pre><code>{ "name": "HTML opener", "description": "Open the current page in popup window", "version": "1.0", "permissions": [ "activeTab" ], "browser_action": { "default_title": "HTML opener", "default_popup": "popup.html" }, "manifest_version": 2 } </code></pre> <p>popup.html:</p> <pre><code>&lt;!doctype html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;Getting Started Extension's Popup&lt;/title&gt; &lt;style&gt; body { min-width: 300px; overflow-x: hidden; } &lt;/style&gt; &lt;script src="popup.js"&gt;&lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>popup.js:</p> <pre><code>chrome.tabs.query( { active: true, lastFocusedWindow: true }, function(array_of_Tabs) { var tab = array_of_Tabs[0]; //tab.url; - url of the active tab chrome.tabs.executeScript(tab.id, {code: "chrome.runtime.sendMessage(document.getElementsByTagName('html')[0].innerHTML);"}); }); chrome.runtime.onMessage.addListener(function(request) { document.getElementsByTagName('html')[0].innerHTML = request; }); </code></pre> <p>If you have any question about the code above, please ask. If you want to read more about chrome.tabs (get information about tabs) and chrome.runtime (send messages between different parts of your extension), you may find these links interesting: <a href="http://developer.chrome.com/extensions/tabs.html" rel="nofollow">http://developer.chrome.com/extensions/tabs.html</a>, <a href="http://developer.chrome.com/extensions/runtime.html" rel="nofollow">http://developer.chrome.com/extensions/runtime.html</a>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload