Open klren0312 opened 10 months ago
{ "permissions": ["system.display"], }
const getScreenInfo = async () => { const list = await chrome.system.display.getInfo() return list } ;(async () => { const list = await getScreenInfo() console.log(list) })()
[ { "activeState": "active", "availableDisplayZoomFactors": [], "bounds": { "height": 960, "left": 0, "top": 0, "width": 1440 }, "displayZoomFactor": 0, "dpiX": 120, "dpiY": 120, "hasAccelerometerSupport": false, "hasTouchSupport": false, "id": "2528732444", "isEnabled": true, "isInternal": true, "isPrimary": true, "isUnified": false, "mirroringDestinationIds": [], "mirroringSourceId": "", "modes": [], "name": "Surface Display", "overscan": { "bottom": 0, "left": 0, "right": 0, "top": 0 }, "rotation": 0, "workArea": { "height": 930, "left": 0, "top": 30, "width": 1440 } } ]
https://developer.chrome.com/docs/extensions/reference/api/system/display?hl=zh-cn
1. manifest.json中添加权限
2. background.js中添加代码
3. 参考资料
https://developer.chrome.com/docs/extensions/reference/api/system/display?hl=zh-cn