Skip to content

Commit 2fdd0dd

Browse files
authored
v1.6.0: 提升速度,修正布局
1 parent 93a7b23 commit 2fdd0dd

1 file changed

Lines changed: 38 additions & 37 deletions

File tree

SpeedRunHelper.user.js

Lines changed: 38 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -11,34 +11,52 @@
1111
let speedrun = {};
1212
let worker = {};
1313
let style = {};
14-
let srFixed = fixedPanePlayer();
1514
let srDrag;
1615
let srY;
1716
let srX;
1817
let srPane = -1;
1918
let srWatch = location.pathname.split('/')?.[1];
20-
var {clientWidth, clientHeight} = document.documentElement;
19+
20+
let { innerHeight, innerWidth } = window;
21+
let fixedX;
22+
let fixedY;
23+
if (innerHeight < 720) {
24+
fixedX = 854;
25+
fixedY = 480;
26+
} else if (innerHeight < 1080) {
27+
fixedX = 1280;
28+
fixedY = 720;
29+
} else if (innerHeight < 1440) {
30+
fixedX = 1920;
31+
fixedY = 1080;
32+
} else if (innerHeight < 2160) {
33+
fixedX = 2560;
34+
fixedY = 1440;
35+
} else {
36+
fixedX = 3840;
37+
fixedY = 2160;
38+
}
2139

2240
let css = document.createElement('style');
2341
css.innerHTML = `
24-
#app-main [class$="lg:w-[400px]"] {display: none !important;}
25-
.speedrun-window {position: absolute; z-index: 999999; display: grid; grid-template-columns: calc(100% - 66px) 66px;}
26-
.speedrun-window iframe {width: ${srFixed.x}px; height: ${srFixed.y}px; grid-column: span 2;}
27-
.speedrun-record, .speedrun-menu {background-color: #181B1C; display: flex; height: 22px;}
28-
.speedrun-record > * {flex: 1; margin: auto; padding: 0px 5px 0px 3px;}
29-
.speedrun-record * {display: inline-block !important;}
30-
.speedrun-record img {height: 16px !important; width: 16px !important; position: relative !important; margin-right: 3px;}
42+
#app-main [class$="lg:w-[400px]"] { display: none !important; }
43+
.speedrun-window { position: absolute; z-index: 999999; display: grid; grid-template-columns: calc(100% - 66px) 66px; }
44+
.speedrun-window iframe { width: ${fixedX}px; height: ${fixedY}px; grid-column: span 2; }
45+
.speedrun-record, .speedrun-menu { background-color: #181B1C; display: flex; height: 22px; }
46+
.speedrun-record > * { flex: 1; margin: auto; padding: 0px 5px 0px 3px; }
47+
.speedrun-record * { display: inline-block !important; }
48+
.speedrun-record img { height: 16px !important; width: 16px !important; position: relative !important; margin-right: 3px; }
3149
.speedrun-menu {margin-left: auto;}
32-
.speedrun-menu > * {background-color: #fff; color: #000; cursor: pointer; height: 20px; width: 20px; font-size: 14px; text-align: center; vertical-align: top; margin-left: 2px;}
33-
.speedrun-menu > :hover {filter: opacity(60%);}
34-
.speedrun-menu > :active {filter: opacity(30%);}
35-
#speedrun-minimum {line-height: 30px;}
36-
.speedrun-minimum {bottom: 0px; left: 0px; width: 30% !important; height: 20px !important; z-index: 99999;}
37-
.speedrun-minimum iframe {display: none !important;}
38-
.speedrun-maximum {top: 0px; left: 0px; width: ${clientWidth}px !important; height: ${clientHeight}px !important; z-index: 999999;}
39-
.speedrun-maximum iframe {width: ${clientWidth}px !important; height: ${clientHeight - 20}px !important;}
40-
#speedrun-restore, .speedrun-minimum #speedrun-minimum, .speedrun-maximum #speedrun-maximum {display: none;}
41-
.speedrun-minimum #speedrun-restore, .speedrun-maximum #speedrun-restore {display: block;}`;
50+
.speedrun-menu > * { background-color: #fff; color: #000; cursor: pointer; height: 20px; width: 20px; font-size: 14px; text-align: center; vertical-align: top; margin-left: 2px; }
51+
.speedrun-menu > :hover { filter: opacity(60%); }
52+
.speedrun-menu > :active { filter: opacity(30%); }
53+
#speedrun-minimum { line-height: 30px; }
54+
.speedrun-minimum { bottom: 0px; left: 0px; width: 30% !important; height: 20px !important; z-index: 99999; }
55+
.speedrun-minimum iframe { display: none !important; }
56+
.speedrun-maximum { top: 0px; left: 0px; width: ${innerWidth - 4}px !important; height: ${innerHeight - 4}px !important; z-index: 999999; }
57+
.speedrun-maximum iframe { width: ${innerWidth - 4}px !important; height: ${innerHeight - 24}px !important; }
58+
#speedrun-restore, .speedrun-minimum #speedrun-minimum, .speedrun-maximum #speedrun-maximum { display: none; }
59+
.speedrun-minimum #speedrun-restore, .speedrun-maximum #speedrun-restore { display: block; }`;
4260
document.body.append(css);
4361

4462
document.querySelector('main').addEventListener('contextmenu', async (event) => {
@@ -158,26 +176,9 @@ ${player}`;
158176

159177
function fixedPanePosition(offset) {
160178
let top = 130 + offset;
161-
let left = (document.documentElement.clientWidth - srFixed.x) / 2 + offset;
179+
let left = (innerWidth - fixedX) / 2 + offset;
162180
if (left < 0) {
163181
left = 0;
164182
}
165183
return `top: ${top}px; left: ${left}px;`;
166184
}
167-
168-
function fixedPanePlayer() {
169-
let {innerHeight} = window;
170-
if (innerHeight < 720) {
171-
return {x: 854, y: 480};
172-
}
173-
if (innerHeight < 1080) {
174-
return {x: 1280, y: 720};
175-
}
176-
if (innerHeight < 1440) {
177-
return {x: 1920, y: 1080};
178-
}
179-
if (innerHeight < 2160) {
180-
return {x: 2560, y: 1440};
181-
}
182-
return {x: 3840, y: 2160};
183-
}

0 commit comments

Comments
 (0)