使用JS以外的任何脚本语言自动删除Firefox中的Cookie集

时间:2019-04-11 20:52:07

标签: python powershell firefox cookies scripting

有人可以对此提供任何指导吗?这真的那么困难吗?电源外壳?蟒蛇?不管怎样,请按正确的方向发送给我。

2 个答案:

答案 0 :(得分:0)

我不确定您为什么需要或想要它-如果是供个人使用,则可以使用扩展名Cookie AutoDelete,该扩展名将在您关闭标签后自动删除您访问的网站的所有cookie。 / p>

答案 1 :(得分:0)

我不确定您要如何实现自动化,但是在PowerShell中,您可以像这样删除Firefox cookie:

if (Get-Process -Name firefox -ErrorAction SilentlyContinue) {
    Write-Warning ("Firefox process(es) are still running. Please close all before removing the cookies.`r`n" +
                   "Use Get-Process -Name firefox -ErrorAction SilentlyContinue | Stop-Process -ErrorAction SilentlyContinue")
}
else {
    $pathRoaming = "$($env:APPDATA)\Mozilla\Firefox\Profiles\*.default*"
    if (Test-Path -Path $pathRoaming -PathType Container) {
        $cookies = @()
        foreach ($path in (Resolve-Path $pathRoaming)) {
            $cookies += Get-ChildItem -Path $path -Filter 'cookies.sqlite*' -Recurse -Force -ErrorAction SilentlyContinue
        }
        # remove cookies. 
        $cookies | ForEach-Object { Remove-Item $_.FullName -Force -Recurse -ErrorAction SilentlyContinue -WhatIf }
    }
}

如果您对控制台中显示的结果感到满意,请从-WhatIf cmdlet中断开Remove-Item开关。

希望有帮助