|
11 | 11 | let speedrun = {}; |
12 | 12 | let worker = {}; |
13 | 13 | let style = {}; |
14 | | -let srFixed = fixedPanePlayer(); |
15 | 14 | let srDrag; |
16 | 15 | let srY; |
17 | 16 | let srX; |
18 | 17 | let srPane = -1; |
19 | 18 | 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 | +} |
21 | 39 |
|
22 | 40 | let css = document.createElement('style'); |
23 | 41 | 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; } |
31 | 49 | .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; }`; |
42 | 60 | document.body.append(css); |
43 | 61 |
|
44 | 62 | document.querySelector('main').addEventListener('contextmenu', async (event) => { |
@@ -158,26 +176,9 @@ ${player}`; |
158 | 176 |
|
159 | 177 | function fixedPanePosition(offset) { |
160 | 178 | let top = 130 + offset; |
161 | | - let left = (document.documentElement.clientWidth - srFixed.x) / 2 + offset; |
| 179 | + let left = (innerWidth - fixedX) / 2 + offset; |
162 | 180 | if (left < 0) { |
163 | 181 | left = 0; |
164 | 182 | } |
165 | 183 | return `top: ${top}px; left: ${left}px;`; |
166 | 184 | } |
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