| 270 | startTime: null |
| 271 | } |
| 272 | function getWindowConfig() { |
| 273 | const windowConfigs = GM_getValue('SitewindowConfigs', [ |
| 274 | ]) |
| 275 | GM_setValue('SitewindowConfigs', windowConfigs |
| 276 | ) |
| 277 | const currentHostName = window.location.hostname |
| 278 | // 顶级规则,查找当前域名是否在设置内..... |
| 279 | for (const config of windowConfigs) { |
| 280 | if (typeof config.hostName === 'string') { |
| 281 | if (config.hostName === currentHostName) { |
| 282 | return { |
| 283 | width: config.width || 870, |
| 284 | height: config.height || 530, |
| 285 | top: config.top || (window.screen.height - (config.height || 530)) / 3, |
| 286 | left: config.left || (window.screen.width - (config.width || 870)) / 2 |
| 287 | } |
| 288 | } |
| 289 | } else if (Array.isArray(config.hostName)) { |
| 290 | if (config.hostName.includes(currentHostName)) { |
| 291 | return { |
| 292 | width: config.width || 870, |
| 293 | height: config.height || 530, |
| 294 | top: config.top || (window.screen.height - (config.height || 530)) / 3, |
| 295 | left: config.left || (window.screen.width - (config.width || 870)) / 2 |
| 296 | } |
| 297 | } |
| 298 | } |
| 299 | } |
| 300 | // 二级规则,如果开启了自定义设置,使用自定义. |
| 301 | const customWindowWidth = GM_getValue('custom_windowWidth', 0) |
| 302 | const customWindowHeight = GM_getValue('custom_windowHeight', 0) |
| 303 | const customScreenLeft = GM_getValue('custom_screenLeft', 0) |
| 304 | const customScreenTop = GM_getValue('custom_screenTop', 0) |
| 305 | if (GM_getValue('saveWindowConfig', false)) { |
| 306 | if (customWindowWidth !== 0 && customWindowHeight !== 0 && customScreenLeft !== 0 && customScreenTop !== 0) { |
| 307 | return { |
| 308 | width: customWindowWidth, |
| 309 | height: customWindowHeight, |
| 310 | top: customScreenTop, |
| 311 | left: customScreenLeft |
| 312 | } |
| 313 | } |
| 314 | } |
| 315 | //三级级规则 以上规则全部找不到,窗口使用默认设置. |
| 316 | return { |
| 317 | width: 870, |
| 318 | height: 530, |
| 319 | top: (window.screen.height - 530) / 3, |
| 320 | left: (window.screen.width - 870) / 2 |
| 321 | } |
| 322 | } |
| 323 | function reWindowConfig() { |
| 324 | const windowConfig = getWindowConfig() |
| 325 | config.windowWidth = windowConfig.width, |