1 Star 0 Fork 0

King/sessionBox

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
overlay.content-script.js 2.91 KB
一键复制 编辑 原始数据 按行查看 历史
king957 提交于 2024-08-03 23:21 +08:00 . 调整
/******/ (() => { // webpackBootstrap
var __webpack_exports__ = {};
///<reference path="../typings/index.d.ts"/>
var ContentScripts;
(function (ContentScripts) {
var Overlay;
(function (Overlay) {
var OverlayInjector = /** @class */ (function () {
function OverlayInjector() {
this.injectedFrames = [];
this.injectedOverlays = [];
}
OverlayInjector.prototype.inject = function (url) {
var iframe = document.createElement('iframe');
iframe.style.position = "fixed";
iframe.style.top = "0";
iframe.style.left = "0";
iframe.style.right = "0";
iframe.style.bottom = "0";
iframe.style.zIndex = "10000000000";
iframe.style.width = "100%";
iframe.style.height = "100%";
document.body.appendChild(iframe);
iframe.src = url;
window.addEventListener('message', function (event) {
if (event.data === "FROM_SR_REMOVE_IFRAME") {
chrome.runtime.sendMessage({ type: 'newSessionFlowFinished' });
document.body.removeChild(iframe);
}
});
this.injectedFrames.push(iframe);
};
OverlayInjector.prototype.run = function () {
var _this = this;
chrome.runtime.onMessage.addListener(function (message) {
if (message.type === 'showOverlay' && _this.injectedOverlays.indexOf(message.payload) === -1) {
_this.injectedOverlays.push(message.payload);
_this.inject(chrome.runtime.getURL(message.payload));
}
else if (message.type === 'removeOverlay') {
_this.injectedFrames.forEach(function (frame) {
document.body.removeChild(frame);
});
_this.injectedFrames.length = 0;
_this.injectedOverlays.length = 0;
}
else if (message.type === 'promptForTemporary') {
var num = prompt("How many temporary session would you like to open?", message.defaultNum);
if (num != null && !isNaN(parseInt(num))) {
chrome.runtime.sendMessage({ type: 'openBulkTemporary', num: parseInt(num) });
}
}
});
};
return OverlayInjector;
}());
function run() {
var script = new OverlayInjector();
script.run();
}
Overlay.run = run;
})(Overlay = ContentScripts.Overlay || (ContentScripts.Overlay = {}));
})(ContentScripts || (ContentScripts = {}));
ContentScripts.Overlay.run();
/******/ })()
;
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/theknight/session-box.git
git@gitee.com:theknight/session-box.git
theknight
session-box
sessionBox
master

搜索帮助