Hide CurseForge ads from the launcher
CurseForge (no ads)
Starts the CurseForge desktop app for Windows with the ad panel on the right hidden. No CurseForge files are changed.
Install
- On this page, click Raw in the top right corner of the
CurseForge-NoAds.ps1box below. - Press Ctrl+A to select all the text, then Ctrl+C to copy it.
- Open Notepad and press Ctrl+V to paste.
- Click File → Save as and:
- pick a folder where the file can stay, for example
C:\Tools(shortcuts made by the script point to this location), - set Save as type to All files (*.*),
- set File name to
CurseForge-NoAds.ps1, - click Save.
- pick a folder where the file can stay, for example
Run
There are two ways to run the script. Pick one.
A. With the menu (easiest)
Right-click CurseForge-NoAds.ps1 and choose Run with PowerShell. A menu opens; type a number and press Enter.
| Option | |
|---|---|
| 1 | Start CurseForge without ads |
| 2 | Create Desktop shortcut |
| 3 | Create Start Menu shortcut (offers to delete the normal one) |
| 4 | Remove shortcuts |
| 5 | Set CurseForge location |
| 6 | Open log file |
| 7 | What does this script do? |
Tip: create a shortcut with option 2 or 3, then always start CurseForge from that shortcut.
B. With parameters (no menu)
For use in your own scripts or shortcuts. Open PowerShell in the script's folder and run, for example:
powershell -NoProfile -ExecutionPolicy Bypass -File .\CurseForge-NoAds.ps1 -Launch
| Parameter | |
|---|---|
-Launch | Start CurseForge without ads |
-CreateShortcut | Create Desktop shortcut |
-CreateStartMenuShortcut | Create Start Menu shortcut |
-RemoveShortcuts | Remove shortcuts |
-ExePath | Where CurseForge is installed, if it is not found automatically |
-LogPath | Where to write the log |
Notes
- Ads are only hidden when CurseForge is started through the script, not when it starts with Windows.
- The log (
CurseForge-NoAds.log, next to the script) ends withAd panel hidden.when it worked. - To undo: remove the shortcuts (option 4) and delete the script.
| <# | |
| .SYNOPSIS | |
| Starts CurseForge with the right-side ad panel hidden. | |
| .DESCRIPTION | |
| No CurseForge files are modified. CurseForge is started with Electron's | |
| main-process inspector bound to 127.0.0.1. The script connects once, | |
| registers a CSS rule that hides the ad panel in every app window (it is | |
| re-applied whenever a window reloads), and then closes the inspector port. | |
| Because nothing on disk is changed, CurseForge updates do not undo this. | |
| If a future update renames the panel's CSS class, the ads will return and | |
| the selector below needs updating. | |
| Run without parameters to get an interactive menu. | |
| .PARAMETER ExePath | |
| Path to CurseForge.exe, or to the folder that contains it. When omitted, | |
| the script looks for it in this order: a running CurseForge process, the | |
| installer's uninstall entry in the registry, Start Menu and Desktop | |
| shortcuts, then common install folders. Given on its own, it starts | |
| CurseForge (same as -Launch). | |
| .PARAMETER Launch | |
| Starts CurseForge without ads, without showing the menu. | |
| .PARAMETER CreateShortcut | |
| Creates a "CurseForge (no ads)" shortcut on the Desktop and exits. | |
| .PARAMETER CreateStartMenuShortcut | |
| Creates a "CurseForge (no ads)" shortcut in the Start Menu and exits. | |
| .PARAMETER RemoveShortcuts | |
| Removes the "CurseForge (no ads)" shortcuts from the Desktop and Start Menu and exits. | |
| .PARAMETER LogPath | |
| Where to write the log file. Defaults to CurseForge-NoAds.log next to | |
| this script, or in %TEMP% if the script's folder cannot be written to. | |
| .EXAMPLE | |
| .\CurseForge-NoAds.ps1 | |
| Shows the menu. | |
| .EXAMPLE | |
| .\CurseForge-NoAds.ps1 -Launch -ExePath "D:\Apps\CurseForge Windows" | |
| #> | |
| param( | |
| [string]$ExePath, | |
| [switch]$Launch, | |
| [switch]$CreateShortcut, | |
| [switch]$CreateStartMenuShortcut, | |
| [switch]$RemoveShortcuts, | |
| [string]$LogPath | |
| ) | |
| $ErrorActionPreference = 'Stop' | |
| $port = 9334 | |
| # Returns $true if the file can be created or appended to. | |
| function Test-Writable([string]$path) { | |
| try { | |
| $dir = Split-Path $path -Parent | |
| if ($dir -and -not (Test-Path -LiteralPath $dir)) { [void](New-Item -ItemType Directory -Path $dir) } | |
| [IO.File]::Open($path, 'Append', 'Write', 'ReadWrite').Dispose() | |
| return $true | |
| } catch { return $false } | |
| } | |
| $log = if ($LogPath) { [Environment]::ExpandEnvironmentVariables($LogPath.Trim('"')) } else { Join-Path $PSScriptRoot 'CurseForge-NoAds.log' } | |
| if (-not (Test-Writable $log)) { $log = Join-Path $env:TEMP 'CurseForge-NoAds.log' } | |
| $log = [IO.Path]::GetFullPath($log) | |
| $shortcutName = 'CurseForge (no ads).lnk' | |
| $shortcutDirs = [ordered]@{ | |
| 'Desktop' = [Environment]::GetFolderPath('Desktop') | |
| 'Start Menu' = Join-Path ([Environment]::GetFolderPath('StartMenu')) 'Programs' | |
| } | |
| $script:Interactive = $false | |
| # A failed log write must never stop CurseForge from starting. | |
| function Add-LogLine($msg) { | |
| try { "$(Get-Date -Format s) $msg" | Out-File -FilePath $log -Append -Encoding utf8 } catch { } | |
| } | |
| function Write-Log($msg) { | |
| Add-LogLine $msg | |
| if ($script:Interactive) { Write-Host " $msg" } | |
| } | |
| # In the menu, errors are shown and the menu continues. Otherwise the script | |
| # usually runs from a shortcut with a hidden window, so errors go to a message box. | |
| function Stop-WithError($msg) { | |
| Add-LogLine $msg | |
| if ($script:Interactive) { throw $msg } | |
| Add-Type -AssemblyName System.Windows.Forms | |
| [void][System.Windows.Forms.MessageBox]::Show($msg, 'CurseForge (no ads)', 'OK', 'Error') | |
| exit 1 | |
| } | |
| # Turns a path, a folder, a quoted path or an icon reference ("...exe,0") into | |
| # a full path to CurseForge.exe, or $null if there is no such file. | |
| function Resolve-CurseForgeExe([string]$path) { | |
| if ([string]::IsNullOrWhiteSpace($path)) { return $null } | |
| $path = [Environment]::ExpandEnvironmentVariables($path.Trim().Trim('"')) | |
| $path = $path -replace ',\s*-?\d+ |