问题描述
我想编写一个脚本来更改Chrome中默认的页面缩放,但是我不知道这些选项的存储位置.我想我必须找到一个适当的选项文本文件,进行解析,然后使用powershell在此处进行文本替换,以应用更改.每当我将笔记本电脑插入外部显示器时,都需要这样做,这真是令人讨厌的手动操作
I want to make a script to change the default page zoom in Chrome, however I do not know where these options are stored.I guess that I have to find an appropriate options text file, parse it, and then make a textual replacement there, using powershell in order to apply the changes.I need to do it every time I plugin my laptop to an external monitor, and it is kinda annowying to do it by hand
有什么想法吗?
推荐答案
默认缩放级别存储在一个名为 Preferences
的巨大JSON配置文件中,该文件可在本地appdata文件夹中找到:
The default zoom level is stored in a huge JSON config file called Preferences
, that can be found in the local appdata folder:
$LocalAppData = [Environment]::GetFolderPath( [Environment+SpecialFolder]::LocalApplicationData )
$ChromeDefaults = Join-Path $LocalAppData "Google\Chrome\User Data\default"
$ChromePrefFile = Join-Path $ChromeDefaults "Preferences"
$Settings = Get-Content $ChromePrefFile | ConvertFrom-Json
默认的页面缩放级别存储在 partition
对象下,尽管它似乎存储为具有某种比率值的唯一标识符,但这是100%缩放的样子:
The default Page Zoom level is stored under the partition
object, although it seems to store it as a unique identifier with some sort of ratio value, this is what it looks like with 100% zoom:
PS C:\> $Settings.partition.default_zoom_level | Format-List
2166136261 : 0.0
除此之外,我不知道.我不认为这是个好主意,每次默认文件更新时,Chrome似乎都会更新一些二进制值,结果可能会损坏 Preferences
文件
Other than that, I have no idea. I don't expect this to be a good idea, Chrome seems to update a number of binary values everytime the default files are updated, you might end up with a corrupt Preferences
file
这篇关于通过Powershell更改Chrome设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!