油猴脚本请教贴

四级用户 s461352 15小时前 549

朋友搭了个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);
})();


1.jpg


上一篇:PSV掉档了,悲痛万分,求一下QCMA以便备份存档
下一篇:有没有一个游戏系列,你曾经是铁粉,但是年纪上来后就不想再玩了
最新回复 (3)
  • 三级用户 a1027794510a 14小时前
    1 2
    因为在iframe里面又执行了一遍  你创建的窗口,这时候,只需要判断是否顶层就行了
  • 三级用户 a1027794510a 14小时前
    0 3
    if(window.self !== window.top){
    console.log(11111)
        return;
    }
  • 四级用户 s461352 12小时前
    0 4
    a1027794510a if(window.self !== window.top){ console.log(11111)    return; }

    神医啊!果然会编程就是牛逼,谢谢!

    1.png

    • 老男人游戏网配套论坛
      5
        立即登录 立即注册
发新帖
本论坛禁止发布SWITCH和PS4相关资源,若有其他侵权内容,请致邮3360342659#qq.com(#替换成@)删除。