|
|
@@ -22,7 +22,7 @@ const getSchemeData = new Promise((resolve, reject) => {
|
|
|
method: 'POST',
|
|
|
headers: myHeaders,
|
|
|
body: JSON.stringify({
|
|
|
- "edition": 7,
|
|
|
+ "edition": 8,
|
|
|
"url": tabInfo.url
|
|
|
}),
|
|
|
redirect: 'follow'
|
|
|
@@ -185,20 +185,46 @@ function load() {
|
|
|
chrome.scripting.executeScript({
|
|
|
target: { tabId: tabData.tabInfo.id },
|
|
|
func: () => {
|
|
|
- // 创建 iframe 并插入页面
|
|
|
- const iframe = document.createElement('iframe');
|
|
|
- iframe.src = 'https://demos.run/assist/index.html'; // 注意:必须同源或对方允许跨源
|
|
|
- iframe.style.width = '300px';
|
|
|
- iframe.style.height = '400px';
|
|
|
- document.body.appendChild(iframe);
|
|
|
-
|
|
|
- // 向 iframe 发送消息
|
|
|
- iframe.onload = () => {
|
|
|
- iframe.contentWindow.postMessage({
|
|
|
- type: "onload",
|
|
|
- value: location.href
|
|
|
- }, '*');
|
|
|
- };
|
|
|
+
|
|
|
+ // 创建div元素
|
|
|
+ const newDiv = document.createElement('div');
|
|
|
+
|
|
|
+ // 设置div的内容和属性
|
|
|
+
|
|
|
+ newDiv.id = 'assistBox';
|
|
|
+ newDiv.className = 'assist-box';
|
|
|
+ newDiv.innerHTML = `
|
|
|
+ <img style="position: absolute;top: -6px;left: -13px;" onclick="window.assistBox.style.right = (window.assistBox.style.right == '-301px' ? '0' : '-301px')" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAA8CAYAAACw00AzAAABtklEQVRIie3WvU7bUBTA8b9vrKSGhKZqyAALWToQVYWhElM3pDbiG8aqcx+Al+jAAzCwdar6QVDLK3SgMDAa0g0JlGTDBmOw0bUasOHGyV2hZ7LO/d2jc+61ZPPQw5Dz2Qd/u405CbwD3piZzIDZRb0APgELnYTn+6jwEvAFyMSTGSGO7uIa8K1bTyL2/Bz4mXZHcbzRGbgXHgHm02Acv+8F43hKB4/qYEsHX+ngvuI/VuIgCMhms+Ryueg5FUvYbDZxXZdCoaDccIPzg4Mcn5ywWd+KXmrVhts2wpBnxSKNRoOv339gmib5fD6xITFgGIaUSsPYts1mvR7l5AwppxFSLpfZ+bPLr+1tBiwLwzDUWAiB4zg8HRqiMlbhwvdv1kwVNAzB8vIi1fFxWq3W/TYkdN0zzs895mZneFmtRlDOcQ9f+j5BGFCrvWVi4hXNf7DTb6KNU8ehUhnDemLRbrejI4vDRGVZRRgCz/OUMFFZLnYuQAWVR5cWjwYnvh+98IVO5WMdvKeDP+tgG/jdL5bxQQcfAh/7xTLWgdV+sYw1YBrYv5Mv9frfWAHmgNeA3w09wgCuAWMViFVtipj2AAAAAElFTkSuQmCC">
|
|
|
+ `;
|
|
|
+ newDiv.style.cssText = `
|
|
|
+ position: fixed;
|
|
|
+ right: 0;
|
|
|
+ bottom: 20px;
|
|
|
+ border: 1px solid #ccc;
|
|
|
+ background-color: rgba(255, 255,255, 0.8);
|
|
|
+ z-index: 99;
|
|
|
+ transition: right 1s ease;
|
|
|
+ `;
|
|
|
+
|
|
|
+ // 将div插入到body的末尾
|
|
|
+ document.body.appendChild(newDiv);
|
|
|
+
|
|
|
+ setTimeout(() => {
|
|
|
+ // 创建 iframe 并插入页面
|
|
|
+ const iframe = document.createElement('iframe');
|
|
|
+ iframe.src = 'https://demos.run/assist/index.html'; // 注意:必须同源或对方允许跨源
|
|
|
+ iframe.style.cssText = `width: 300px;height: 400px;border: none;`
|
|
|
+ window.assistBox.appendChild(iframe);
|
|
|
+
|
|
|
+ // 向 iframe 发送消息
|
|
|
+ iframe.onload = () => {
|
|
|
+ iframe.contentWindow.postMessage({
|
|
|
+ type: "onload",
|
|
|
+ value: location.href
|
|
|
+ }, '*');
|
|
|
+ };
|
|
|
+ }, 0);
|
|
|
+
|
|
|
|
|
|
// 接收子页面发来的消息
|
|
|
window.addEventListener('message', (event) => {
|