// ==UserScript== // @name FloatingFrameUI // @author xiaofeiwu // @version 1.0.0 // ==/UserScript== function FloatingFrameUI() { var floatingBox = function (options) { // 默认配置项 var defaults = { content: 'Hello World', // 悬浮框内容 width: '200px', height: '200px', backgroundColor: 'skyblue', color: '#fff', // 文字颜色 background: '#333', // 背景颜色 padding: '10px', // 内边距 borderRadius: '5px', // 圆角半径 boxShadow: '0 0 10px rgba(0, 0, 0, 0.3)', // 阴影效果 position: { // 悬浮框位置 top: '50px', left: '50px', } }; console.log(options) // 合并配置项 var settings = Object.assign({}, defaults, options); console.log(settings) // 创建悬浮框元素 var box = document.createElement('div'); box.style.position = 'fixed'; box.style.top = settings.position.top; box.style.left = settings.position.left; box.style.width = settings.width; box.style.height = settings.height; box.style.color = settings.color; box.style.background =settings.background; box.style.padding = settings.padding; box.style.borderRadius = settings.borderRadius; box.style.boxShadow = settings.boxShadow; // box.style.backgroundColor = settings.position.backgroundColor; box.innerHTML = settings.content; // 添加悬浮框元素到页面 document.body.appendChild(box); // 返回悬浮框元素 return box; }; return floatingBox; }