Advertisement
anonit

Configure uBOL first run and exclusions via Powershell

Nov 7th, 2024
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #### Configure uBOL first run and exclusions via Powershell
  2.  
  3. $urls=@"
  4. anonit.net
  5. example.com
  6. "@ -split "`n" | % {$_.trim()}
  7.  
  8.  
  9. ### CHROME
  10.  
  11. # Registry key location for uBlock Origin Lite's filtering exemptions
  12.     $keyLocation = "HKLM:\SOFTWARE\Policies\Google\Chrome\3rdparty\extensions\ddkjiahejlhfcafbddmgiahcphecmpfh\policy\"
  13.     $firstRunValue = "disableFirstRunPage"
  14.     $firstRunSetting = $keyLocation+$firstRunValue
  15.     $noFilteringValue = "noFiltering"
  16.     $noFilteringSetting = $keyLocation+$noFilteringValue
  17.  
  18.  
  19. # Check if Disable first run is set, if not set it.
  20.     if (!(test-path -path $firstRunSetting)) {
  21.         new-item -path $keyLocation -force
  22.         new-itemProperty -path $keyLocation -name $FirstRunValue -value "1" -propertyType DWORD -force
  23.     }
  24.  
  25. # Remove noFiltering key if it already exists. Clearing the decks makes updating an existing list far less complicated.
  26.     if (test-path -path $noFilteringSetting) {remove-item -path $noFilteringSetting}
  27.     new-item -path $keyLocation -name $noFilteringValue -force
  28.     # Iterate through the content of $urls and write numbered values to the noFiltering key
  29.     $urlCount = 0
  30.     $urls | % -process {
  31.         $urlCount++
  32.         new-itemProperty -path $noFilteringSetting -name "$urlCount" -value "$_" -propertyType String -force
  33. }
  34.  
  35.  
  36. ### EDGE
  37.  
  38. # Registry key location for uBlock Origin Lite's filtering exemptions
  39.     $keyLocation = "HKLM:\SOFTWARE\Policies\Microsoft\Edge\3rdparty\extensions\cimighlppcgcoapaliogpjjdehbnofhn\policy\"
  40.     $firstRunValue = "disableFirstRunPage"
  41.     $firstRunSetting = $keyLocation+$firstRunValue
  42.     $noFilteringValue = "noFiltering"
  43.     $noFilteringSetting = $keyLocation+$noFilteringValue
  44.  
  45.  
  46. # Check if Disable first run is set, if not set it.
  47.     if (!(test-path -path $firstRunSetting)) {
  48.         new-item -path $keyLocation -force
  49.         new-itemProperty -path $keyLocation -name $FirstRunValue -value "1" -propertyType DWORD -force
  50.     }
  51.  
  52. # Remove the old filters and add new ones
  53.     if (test-path -path $noFilteringSetting) {remove-item -path $noFilteringSetting}
  54.     new-item -path $keyLocation -name $noFilteringValue -force
  55.     $urlCount = 0
  56.     $urls | % -process {
  57.         $urlCount++
  58.         new-itemProperty -path $noFilteringSetting -name "$urlCount" -value "$_" -propertyType String -force
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement