Maximilian
By: a guest | May 30th, 2010 | Syntax:
Power Shell | Size: 1.44 KB | Hits: 161 | Expires: Never
#Opera AdFilter Update Script (c) Maximilian Krauß http://maximiliankrauss.net
#Filterliste (c) Fanboy http://www.fanboy.co.nz/
$operaProfilePath = [System.IO.Path]::Combine([System.Environment]::GetFolderPath("ApplicationData"), "Opera\Opera")
$operaProfileExists = test-path $operaProfilePath -pathType container
$filterPath = [System.IO.Path]::Combine([System.Environment]::GetFolderPath("ApplicationData"), "Opera\Opera\urlfilter.ini")
#Das Script abbrechen falls das Operaprofil nicht gefunden wurde
if(!$operaProfileExists)
{
return;
}
#Aktuelle Filterdaten einlesen, falls vorhanden
$currentFilterContent = "";
if(test-path -PathType Leaf $filterPath) {
$currentFilterContent = Get-Content ($filterPath)
}
$wcl = new-object System.Net.WebClient
$fanboyFilterData = "";
$fanboyFilterUrl = "http://fanboy.co.nz/adblock/opera/urlfilter.ini";
$fanboyFilterData = $wcl.DownloadString($fanboyFilterUrl)
#Überprüfen ob die heruntergeladene Fanboy-Filterversion neuer ist:
if($currentFilterContent -ne $fanboyFilterData) {
#Falls Opera läuft diesen killen:
Stop-Process -name opera
#Neue Filterdaten in Datei schreiben:
[System.IO.File]::WriteAllText($filterPath, $fanboyFilterData);
#Opera starten
Start-Process "C:\Program Files\Opera\opera.exe";
write-host "Update erfolgreich ausgeführt.";
}
else { #Nix zu tun.
write-host "Kein Update notwendig.";
}