├── Enable-devtools.bat ├── Enable-devtools.ps1 ├── README.md └── res ├── diag.spa └── message-visualization.spa /Enable-devtools.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | :: line for changing parameters, each parameter should be separated by a space 4 | :: example: 5 | :: set param=-extra -minimized 6 | set param= 7 | 8 | set url='https://raw.githubusercontent.com/amd64fox/Enable-devtools-Spotify/main/Enable-devtools.ps1' 9 | set tls=[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12; 10 | 11 | %SYSTEMROOT%\System32\WindowsPowerShell\v1.0\powershell.exe ^ 12 | -Command %tls% $p='%param%'; """ & { $(iwr -useb %url%)} $p """" | iex 13 | 14 | exit /b -------------------------------------------------------------------------------- /Enable-devtools.ps1: -------------------------------------------------------------------------------- 1 | param ( 2 | [switch]$allow_pasting, 3 | [switch]$console, 4 | [switch]$minimized, 5 | [switch]$extra 6 | ) 7 | 8 | function Kill-Spotify { 9 | param ( 10 | [int]$maxAttempts = 5 11 | ) 12 | for ($attempt = 1; $attempt -le $maxAttempts; $attempt++) { 13 | $spotifyProcesses = Get-Process -ErrorAction SilentlyContinue | Where-Object { $_.ProcessName -like "Spotify" } 14 | if ($spotifyProcesses) { 15 | foreach ($process in $spotifyProcesses) { 16 | Stop-Process -Id $process.Id -Force -ErrorAction SilentlyContinue 17 | } 18 | Start-Sleep -Milliseconds 500 19 | } 20 | else { 21 | break 22 | } 23 | } 24 | if ($attempt -gt $maxAttempts) { 25 | Write-Host "The maximum number of attempts to terminate a process has been reached." 26 | } 27 | } 28 | 29 | function Update-BNKFile { 30 | param ( 31 | [string]$bnk 32 | ) 33 | 34 | $ANSI = [Text.Encoding]::GetEncoding(1251) 35 | $old = [IO.File]::ReadAllText($bnk, $ANSI) 36 | 37 | $pattern = '(?<=app-developer..|app-developer>)' 38 | 39 | switch -Regex ($old) { 40 | "${pattern}2" { 41 | $new = $old -replace "${pattern}2", '1' 42 | $global:foundPattern2 = $true 43 | } 44 | "${pattern}[01]" { 45 | $new = $old -replace "${pattern}[01]", '2' 46 | } 47 | } 48 | 49 | if ($new -ne $null) { 50 | [IO.File]::WriteAllText($bnk, $new, $ANSI) 51 | } 52 | 53 | } 54 | 55 | function Check-Os { 56 | param( 57 | [string]$check 58 | ) 59 | 60 | $osVersions = @{ 61 | "win7" = "6.1" 62 | "win8" = "6.2, 6.3" 63 | "win10" = "10.0" 64 | } 65 | 66 | $currentVersion = "$(([System.Environment]::OSVersion.Version).Major).$(([System.Environment]::OSVersion.Version).Minor)" 67 | 68 | foreach ($version in $check -split ", ") { 69 | if ($osVersions.ContainsKey($version) -and $osVersions[$version] -contains $currentVersion) { 70 | return $true 71 | } 72 | } 73 | 74 | return $false 75 | } 76 | 77 | function extraApps { 78 | 79 | param( 80 | [Alias("apps")] 81 | [string]$folderApps, 82 | [switch]$extra 83 | ) 84 | 85 | $diagPath = Join-Path -Path $folderApps -ChildPath "diag.spa" 86 | $visualPath = Join-Path -Path $folderApps -ChildPath "message-visualization.spa" 87 | 88 | if (!$extra -or $global:foundPattern2) { 89 | return $false 90 | } 91 | 92 | if ((Test-Path $folderApps -PathType Container)) { 93 | if ((-not (Test-Path $diagPath -PathType Leaf) -or (Get-Item $diagPath).Length -le 10240) -or 94 | (-not (Test-Path $visualPath -PathType Leaf) -or (Get-Item $visualPath).Length -le 307200)) { 95 | return $true 96 | } 97 | else { 98 | return $false 99 | } 100 | } 101 | else { 102 | New-Item -Path $folderApps -ItemType Directory | Out-Null 103 | return $true 104 | } 105 | } 106 | 107 | function Prepare-Paths { 108 | 109 | $psv = $PSVersionTable.PSVersion.major 110 | 111 | if ($psv -ge 7) { 112 | Import-Module Appx -UseWindowsPowerShell -WarningAction:SilentlyContinue 113 | } 114 | 115 | if ((Check-Os "win8, win10") -and (Get-AppxPackage -Name SpotifyAB.SpotifyMusic)) { 116 | 117 | $spotify_exe = Get-Command -Name Spotify 118 | $spotifyFolder = Get-ChildItem "$env:LOCALAPPDATA\Packages\" -Filter "SpotifyAB.SpotifyMusic*" -Directory | Select-Object -ExpandProperty FullName 119 | $offline_bnk = Join-Path $spotifyFolder "LocalState\Spotify\offline.bnk" 120 | $apps = Join-Path $spotifyFolder "LocalState\Spotify\Apps" 121 | $bnkCheck = (Test-Path -LiteralPath $offline_bnk) 122 | 123 | if ($null -ne $spotify_exe -and $bnkCheck) { 124 | return @{ 125 | exe = $spotify_exe.Source 126 | bnk = $offline_bnk 127 | apps = extraApps -apps $apps -extra:$extra 128 | folderApp = $apps 129 | } 130 | } 131 | else { 132 | if ($null -eq $spotify_exe) { 133 | Write-Warning "could not find Spotify.exe for MS, please install/reinstall Spotify" 134 | pause 135 | exit 136 | } 137 | else { 138 | Write-Warning "could not find offline.bnk for MS, please login to Spotify" 139 | pause 140 | exit 141 | } 142 | 143 | } 144 | } 145 | else { 146 | 147 | $spotify_exe = "$env:APPDATA\Spotify\Spotify.exe" 148 | $spotiCheck = (Test-Path -LiteralPath $spotify_exe) 149 | $offline_bnk = "$env:LOCALAPPDATA\Spotify\offline.bnk" 150 | $apps = "$env:LOCALAPPDATA\Spotify\Apps" 151 | $bnkCheck = (Test-Path -LiteralPath $offline_bnk) 152 | 153 | if ($spotiCheck -and $bnkCheck) { 154 | return @{ 155 | exe = $spotify_exe 156 | bnk = $offline_bnk 157 | apps = extraApps -apps $apps -extra:$extra 158 | folderApp = $apps 159 | } 160 | } 161 | else { 162 | if (!($spotiCheck)) { 163 | Write-Warning "could not find Spotify.exe, please install/reinstall Spotify" 164 | pause 165 | exit 166 | } 167 | else { 168 | Write-Warning "could not find offline.bnk, please login to Spotify" 169 | pause 170 | exit 171 | } 172 | } 173 | } 174 | } 175 | 176 | function Dw-Spa { 177 | 178 | param( 179 | [Alias("apps")] 180 | [string]$folderApps 181 | ) 182 | 183 | $url = "https://raw.githubusercontent.com/amd64fox/Enable-devtools-Spotify/main/res/{0}.spa" 184 | $path = "$folderApps\{0}.spa" 185 | $n = ("diag", "message-visualization") 186 | 187 | function Dw { 188 | 189 | param ( 190 | [Alias("u")] 191 | [string]$url, 192 | 193 | [Alias("p")] 194 | [string]$path 195 | ) 196 | 197 | Invoke-RestMethod -Uri $url -OutFile $path 198 | } 199 | 200 | $n | ForEach-Object { Dw -u ($url -f $_) -p ($path -f $_) } 201 | 202 | } 203 | 204 | Kill-Spotify 205 | 206 | $p = Prepare-Paths 207 | 208 | if ($p.apps) { $null = Dw-Spa -apps $p.folderApp } 209 | 210 | $foundPattern2 = $false 211 | 212 | Update-BNKFile -bnk $p.bnk 213 | 214 | $startProcessArgs = @() 215 | $params = @{} 216 | 217 | if (-not $foundPattern2) { 218 | if ($allow_pasting) { 219 | $startProcessArgs += "--unsafely-disable-devtools-self-xss-warnings" 220 | } 221 | if ($console) { 222 | $startProcessArgs += "--show-console" 223 | } 224 | if ($minimized) { 225 | $startProcessArgs += "--minimized" 226 | } 227 | } 228 | 229 | if ($startProcessArgs) { 230 | $params["ArgumentList"] = $startProcessArgs 231 | } 232 | 233 | $params["FilePath"] = $p.exe 234 | 235 | Start-Process @params -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |
2 |

Enable devtools in Spotify for Windows

3 |
4 | 5 |

Requirements:

6 | 7 | - Spotify Desktop or Microsoft Store version 8 | 9 | > [!IMPORTANT] 10 | Spotify client must already be installed and logged in 11 | 12 |

What does the script do?

13 | 14 | - Activates the main developer options in the menu 15 | - Activates the developer menu on the right mouse click 16 | - Additional launch [parameters](https://github.com/amd64fox/Enable-devtools-Spotify?tab=readme-ov-file#script-parameters) 17 | 18 | > [!NOTE] 19 | After closing the client, all developer menus will be disabled, for new versions of the client this logic has stopped working, to disable devtools just run the script again 20 | 21 |

Quick start:

22 | 23 | 24 | #### Just download and run [Enable-devtools.bat](https://raw.githack.com/amd64fox/Enable-devtools-Spotify/main/Enable-devtools.bat) 25 | 26 | or 27 | 28 | #### Run The following command in PowerShell: 29 | 30 | ```ps1 31 | iex "& {$(iwr -useb 'https://raw.githubusercontent.com/amd64fox/Enable-devtools-Spotify/main/Enable-devtools.ps1')}" 32 | ``` 33 | ```ps1 34 | iex "& {$(iwr -useb 'https://raw.githubusercontent.com/amd64fox/Enable-devtools-Spotify/main/Enable-devtools.ps1')} -extra" 35 | ``` 36 | 37 |

38 | 39 | 40 | ## Script parameters: 41 | 42 | | Parameter | Description | 43 | |------------------|-----------------------------------------------------------------------| 44 | | `-extra` | Enable Cosmos debugger & Utils (requires additional resource loading) | 45 | | `-console` | Show console output | 46 | | `-allow_pasting` | Allow pasting in devtools console | 47 | | `-minimized` | Minimize client at start | 48 | 49 | 50 | > [!NOTE] 51 | [Enable-devtools-Spotify](https://gist.github.com/jetfir3/d66f491d0683e2bdbdf9f60068e9984b) (Mac & Linux) by [jetfire](https://github.com/jetfir3) 52 | -------------------------------------------------------------------------------- /res/diag.spa: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amd64fox/Enable-devtools-Spotify/72710721bbb2413d542bb572ae35b663b088ff80/res/diag.spa -------------------------------------------------------------------------------- /res/message-visualization.spa: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amd64fox/Enable-devtools-Spotify/72710721bbb2413d542bb572ae35b663b088ff80/res/message-visualization.spa --------------------------------------------------------------------------------