// ==UserScript==
// @name 视频旋转 & 浮层播放
// @namespace tampermonkey-video-rotate-overlay
// @version 1.1.0
// @description 为 Bilibili 和 YouTube 的 HTML5 视频添加旋转和浮层播放控制
// @author oleyeye
// @license MIT
// @match *://*.bilibili.com/*
// @match *://*.youtube.com/*
// @grant none
// @run-at document-idle
// @downloadURL https://update.greasyfork.icu/scripts/574027/%E8%A7%86%E9%A2%91%E6%97%8B%E8%BD%AC%20%20%E6%B5%AE%E5%B1%82%E6%92%AD%E6%94%BE.user.js
// @updateURL https://update.greasyfork.icu/scripts/574027/%E8%A7%86%E9%A2%91%E6%97%8B%E8%BD%AC%20%20%E6%B5%AE%E5%B1%82%E6%92%AD%E6%94%BE.meta.js
// ==/UserScript==
(function () {
'use strict';
// ─────────────────────────────────────────────────────────────────────
// Module: utils · 通用 DOM / 样式工具
// ─────────────────────────────────────────────────────────────────────
const utils = {
/** 创建 DOM 元素,支持设置 attributes 和 inline styles */
el(tag, attrs = {}, styles = {}) {
const node = document.createElement(tag);
for (const [k, v] of Object.entries(attrs)) node.setAttribute(k, v);
Object.assign(node.style, styles);
return node;
},
/** 向
注入一段 CSS */
injectCSS(css) {
const s = document.createElement('style');
s.textContent = css;
document.head.appendChild(s);
},
/** 将数值限制在 [lo, hi] 区间 */
clamp(v, lo, hi) { return Math.min(Math.max(v, lo), hi); },
};
// ─────────────────────────────────────────────────────────────────────
// Module: videoDetector · 识别页面中渲染面积最大的