(width, height, left, top, HostName = window.location.hostname)
| 692 | return menuCommandId |
| 693 | } |
| 694 | function saveWindowConfig(width, height, left, top, HostName = window.location.hostname) { |
| 695 | config.windowWidth = width |
| 696 | config.windowHeight = height |
| 697 | config.screenLeft = left |
| 698 | config.screenTop = top |
| 699 | const currentHostName = HostName |
| 700 | let windowConfigs = GM_getValue('SitewindowConfigs', [] |
| 701 | ) |
| 702 | let configUpdated = false |
| 703 | for (let config of windowConfigs) { |
| 704 | if (typeof config.hostName === 'string') { |
| 705 | if (config.hostName === currentHostName) { |
| 706 | config.width = width |
| 707 | config.height = height |
| 708 | config.top = top |
| 709 | config.left = left |
| 710 | configUpdated = true |
| 711 | break |
| 712 | } |
| 713 | } else if (Array.isArray(config.hostName)) { |
| 714 | if (config.hostName.includes(currentHostName)) { |
| 715 | config.width = width |
| 716 | config.height = height |
| 717 | config.top = top |
| 718 | config.left = left |
| 719 | configUpdated = true |
| 720 | break |
| 721 | } |
| 722 | } |
| 723 | } |
| 724 | if (!configUpdated) { |
| 725 | windowConfigs.push({ |
| 726 | name: `${currentHostName}`, |
| 727 | hostName: currentHostName, |
| 728 | width: width, |
| 729 | height: height, |
| 730 | top: top, |
| 731 | left: left |
| 732 | }) |
| 733 | } |
| 734 | //ANCHOR - 开启记录窗口位置时.无法找到配置时,会推送一个新配置,当其他的网站没有自定义配置的也同样使用这一次的窗口.大小. |
| 735 | GM_setValue('SitewindowConfigs', windowConfigs) |
| 736 | GM_setValue('custom_windowWidth', width) |
| 737 | GM_setValue('custom_windowHeight', height) |
| 738 | GM_setValue('custom_screenLeft', left) |
| 739 | GM_setValue('custom_screenTop', top) |
| 740 | updateMenuCommands() |
| 741 | } |
| 742 | function toggleSwitch(property) { |
| 743 | if (property in config) { |
| 744 | config[property] = !config[property] |
no test coverage detected