Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- ...
- "content_security_policy": "script-src 'self'; object-src 'self'; frame-src https://www.example.com; child-src https://www.example.com",
- "background": {
- "scripts": [
- "js/jquery/jquery.min.js",
- "src/bg/background.min.js"
- ],
- "persistent": true
- },
- ...
- "content_scripts": [
- {
- ...
- "css": [
- ...
- "src/inject/inject.min.css"
- ],
- "js": [
- ...
- "src/inject/inject.min.js"
- ]
- }
- ],
- "externally_connectable": {
- "matches": [
- "*://localhost/*",
- "*://*.example.com/*
- ]
- },
- "web_accessible_resources": [
- "src/inject/inject.html",
- "src/inject/infobar.html",
- "src/inject/infobar.min.js",
- "src/inject/frame.html"
- ],
- "sandbox": {
- "pages": [
- "src/inject/infobar.html",
- "src/inject/frame.html"
- ]
- }
- }
- var iframe = document.createElement("iframe");
- iframe.scrolling = "no";
- iframe.style.cssText = "display:none;";
- ...
- $(iframe).load(function () {
- var message = {
- command: "render-frame",
- context: data,
- frameUrl: chrome.runtime.getURL("src/inject/frame.html")
- };
- iframe.contentWindow.postMessage(message, '*');
- iframe.style.cssText = "border: 0px; overflow: visible; padding: 0px; right: auto; width: 100%; height: " + toolbarHeight + "px; top: 0px; left: 0px; z-index: 2147483647; box-shadow: rgba(0, 0, 0, 0.498039) 0px 3px 10px; position: fixed; display: none;";
- });
- ...
- iframe.src = chrome.runtime.getURL("src/inject/infobar.html");
- ...
- document.documentElement.appendChild(iframe);
- window.addEventListener("message", function (event) {
- var command = event.data.command;
- switch (command) {
- case "render-frame":
- var frame = document.createElement("iframe");
- frame.scrolling = "no";
- frame.src = event.data.frameUrl;
- document.getElementById("content").appendChild(frame);
- ...
- break;
- }
- });
- <html>
- <head>
- <style>
- html, body, iframe, h2 {
- margin: 0;
- border: 0;
- padding: 0;
- display: block;
- width: 100vw;
- height: 100vh;
- background: white;
- color: black;
- }
- </style>
- </head>
- <body>
- <iframe src="https://www.example.com/page.html"></iframe>
- </body>
- </html>
Add Comment
Please, Sign In to add comment