朋友搭了个GPT网站,然后我想用油猴脚本 弄个悬浮框,并将这个GPT网站嵌套进去,这样我打开网页相当于一个助手随时任我把玩~,这个脚本也是让GPT写的,但是运行之后悬浮框中重复出现了一个,我只想显示底层的这个,GPT怎么改都改不了。。请教下是哪里出问题?
// ==UserScript==
// @name Draggable and Scalable Floating Website
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Embed a website in a floating frame that is draggable and scalable on all sites
// @author You
// @match *://*/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
// Remove any existing floating frame
var existingFrame = document.getElementById('floatingFrame');
if (existingFrame) {
existingFrame.parentNode.removeChild(existingFrame);
}
// Create a loading indicator
var loadingFrame = document.createElement('div');
loadingFrame.id = 'loadingFrame';
loadingFrame.textContent = 'Loading...';
loadingFrame.style.position = 'fixed';
loadingFrame.style.top = '50%';
loadingFrame.style.left = '50%';
loadingFrame.style.transform = 'translate(-50%, -50%)';
loadingFrame.style.zIndex = '9999';
document.body.appendChild(loadingFrame);
// Create a floating frame
var frame = document.createElement('iframe');
frame.id = 'floatingFrame';
frame.src = 'https://xxx.xxx.com/#/chat';
frame.style.display = 'none'; // Hide the frame initially
frame.style.position = 'fixed';
frame.style.top = '200px';
frame.style.right = '200px';
frame.style.width = '600px';
frame.style.height = '600px';
frame.style.border = '1px solid #000';
frame.style.zIndex = '9999';
frame.style.resize = 'both'; // Allow resizing
frame.style.overflow = 'auto'; // Show scrollbars when content exceeds frame size
// Make the frame draggable
var isDragging = false;
var offsetX, offsetY;
frame.addEventListener('mousedown', function(e) {
isDragging = true;
offsetX = e.clientX - frame.getBoundingClientRect().left;
offsetY = e.clientY - frame.getBoundingClientRect().top;
});
document.addEventListener('mousemove', function(e) {
if (isDragging) {
frame.style.top = (e.clientY - offsetY) + 'px';
frame.style.left = (e.clientX - offsetX) + 'px';
}
});
document.addEventListener('mouseup', function() {
isDragging = false;
});
frame.addEventListener('load', function() {
loadingFrame.style.display = 'none'; // Hide the loading indicator
frame.style.display = 'block'; // Show the frame after loading
});
document.body.appendChild(frame);
})();
上一篇:
PSV掉档了,悲痛万分,求一下QCMA以便备份存档下一篇:
有没有一个游戏系列,你曾经是铁粉,但是年纪上来后就不想再玩了