Guest
Public paste!

Maximilian

By: a guest | May 30th, 2010 | Syntax: Power Shell | Size: 1.44 KB | Hits: 161 | Expires: Never
Copy text to clipboard
  1. #Opera AdFilter Update Script (c) Maximilian Krauß http://maximiliankrauss.net
  2. #Filterliste (c) Fanboy http://www.fanboy.co.nz/
  3.  
  4. $operaProfilePath   = [System.IO.Path]::Combine([System.Environment]::GetFolderPath("ApplicationData"), "Opera\Opera")
  5. $operaProfileExists = test-path $operaProfilePath -pathType container
  6. $filterPath         = [System.IO.Path]::Combine([System.Environment]::GetFolderPath("ApplicationData"), "Opera\Opera\urlfilter.ini")
  7.  
  8. #Das Script abbrechen falls das Operaprofil nicht gefunden wurde
  9. if(!$operaProfileExists)
  10. {
  11.     return;
  12. }
  13.  
  14. #Aktuelle Filterdaten einlesen, falls vorhanden
  15. $currentFilterContent = "";
  16. if(test-path -PathType Leaf $filterPath) {
  17.     $currentFilterContent = Get-Content ($filterPath)
  18. }
  19.  
  20. $wcl              = new-object System.Net.WebClient
  21. $fanboyFilterData = "";
  22. $fanboyFilterUrl  = "http://fanboy.co.nz/adblock/opera/urlfilter.ini";
  23. $fanboyFilterData = $wcl.DownloadString($fanboyFilterUrl)
  24.  
  25. #Überprüfen ob die heruntergeladene Fanboy-Filterversion neuer ist:
  26. if($currentFilterContent -ne $fanboyFilterData) {
  27.     #Falls Opera läuft diesen killen:
  28.     Stop-Process -name opera
  29.    
  30.     #Neue Filterdaten in Datei schreiben:
  31.     [System.IO.File]::WriteAllText($filterPath, $fanboyFilterData);
  32.    
  33.     #Opera starten
  34.     Start-Process "C:\Program Files\Opera\opera.exe";
  35.     write-host "Update erfolgreich ausgeführt.";
  36. }
  37. else { #Nix zu tun.
  38.     write-host "Kein Update notwendig.";
  39. }