mamont1
18-07-2011, 12:51
скрипт
option explicit
'original download code by ilboso http://www.srware.net/forum/viewtopic.php?f=18&t=1971
' -----------------------------------------------------------------------------
' PARAMETERS
' -----------------------------------------------------------------------------
const source = "https://secure.fanboy.co.nz/opera/urlfilter.ini" 'Opera list, for Iron list use "https://secure.fanboy.co.nz/iron/adblock.ini"
const destination = "C:\Program Files\SRWare Iron\adblock.ini" 'for 64bit use : "C:\Program Files (x86)\SRWare Iron\adblock.ini" or similar
const myfilter = "C:\Program Files\SRWare Iron\myfilter.txt" 'List with your own links, if you dont want this use: ""
' -----------------------------------------------------------------------------
' download adblock.ini
GetHtmlPage source, destination
' Replace code for Opera List
Operastuff destination, "*", ""
Operastuff destination, "#", "# "
' Add your own adblock's from myfilter file
Mylist destination, myfilter
' show message
dim s : s = ReadFirstLines(destination, 3)
dim fso, File
Dim WshShell
Set WshShell = CreateObject("WScript.Shell")
WshShell.popup s, 3, "Adblock.ini updated", 64
sub GetHtmlPage (up_http, down_http)
dim xmlhttp : set xmlhttp = createobject("msxml2.xmlhttp.3.0")
xmlhttp.open "get", up_http, false
xmlhttp.send
dim fso : set fso = createobject ("scripting.filesystemobject")
dim newfile : set newfile = fso.createtextfile(down_http, true)
'and the text from the XMLHTTP response can then be written to the file:
newfile.write (xmlhttp.responseText)
'the file must then be closed:
newfile.close
set newfile = nothing
set xmlhttp = nothing
set fso = nothing
end sub
sub Operastuff (fileName, Replace1, Replace2)
' Replace code for Opera List
Dim fsodat : Set fsodat = CreateObject("Scripting.FileSystemObject")
Dim T1 : T1 = fsodat.OpenTextFile(fileName).ReadAll
fsodat.CreateTextFile(fileName).Write Replace(T1, Replace1, Replace2)
set fsodat = nothing
end sub
sub Mylist (adfilter, linklist)
' Add your own adblock's from myfilter file
Dim objFSO : Set objFSO = CreateObject("Scripting.FileSystemObject")
IF objFSO.FileExists(linklist) THEN
Dim objTextFile : Set objTextFile = objFSO.OpenTextFile(linklist, 1)
Dim strText : strText = objTextFile.ReadAll
Dim AdFile : Set AdFile = objFSO.OpenTextFile(adfilter, 8)
AdFile.WriteLine strText
AdFile.Close
ELSE 'wscript.echo "Sorry, the myfilter file does not exist"
END IF
set objFSO = nothing
end sub
function ReadFirstLines(fileName, numberOfLines)
const wChar = "§"
dim res
' open text file
dim fso : set fso = createobject ("scripting.filesystemobject")
dim ts : set ts = fso.OpenTextFile(fileName)
' read the first x lines
dim x
for x = 1 to numberOfLines
res = res & ts.ReadLine & wChar
next
ts.close
set ts = Nothing
set fso = Nothing
' format output string
if len(res) > 1 then
res = left(res, len(res) - 1)
res = replace(res, wChar, vbCrlf)
end if
ReadFirstLines = res
end function
как, уйти от полных путей в
const destination = "C:\Program Files\SRWare Iron\adblock.ini"
const myfilter = "C:\Program Files\SRWare Iron\myfilter.txt"
если:- скрипт, adblock.ini, myfilter.txt - лежат в одной папке?
option explicit
'original download code by ilboso http://www.srware.net/forum/viewtopic.php?f=18&t=1971
' -----------------------------------------------------------------------------
' PARAMETERS
' -----------------------------------------------------------------------------
const source = "https://secure.fanboy.co.nz/opera/urlfilter.ini" 'Opera list, for Iron list use "https://secure.fanboy.co.nz/iron/adblock.ini"
const destination = "C:\Program Files\SRWare Iron\adblock.ini" 'for 64bit use : "C:\Program Files (x86)\SRWare Iron\adblock.ini" or similar
const myfilter = "C:\Program Files\SRWare Iron\myfilter.txt" 'List with your own links, if you dont want this use: ""
' -----------------------------------------------------------------------------
' download adblock.ini
GetHtmlPage source, destination
' Replace code for Opera List
Operastuff destination, "*", ""
Operastuff destination, "#", "# "
' Add your own adblock's from myfilter file
Mylist destination, myfilter
' show message
dim s : s = ReadFirstLines(destination, 3)
dim fso, File
Dim WshShell
Set WshShell = CreateObject("WScript.Shell")
WshShell.popup s, 3, "Adblock.ini updated", 64
sub GetHtmlPage (up_http, down_http)
dim xmlhttp : set xmlhttp = createobject("msxml2.xmlhttp.3.0")
xmlhttp.open "get", up_http, false
xmlhttp.send
dim fso : set fso = createobject ("scripting.filesystemobject")
dim newfile : set newfile = fso.createtextfile(down_http, true)
'and the text from the XMLHTTP response can then be written to the file:
newfile.write (xmlhttp.responseText)
'the file must then be closed:
newfile.close
set newfile = nothing
set xmlhttp = nothing
set fso = nothing
end sub
sub Operastuff (fileName, Replace1, Replace2)
' Replace code for Opera List
Dim fsodat : Set fsodat = CreateObject("Scripting.FileSystemObject")
Dim T1 : T1 = fsodat.OpenTextFile(fileName).ReadAll
fsodat.CreateTextFile(fileName).Write Replace(T1, Replace1, Replace2)
set fsodat = nothing
end sub
sub Mylist (adfilter, linklist)
' Add your own adblock's from myfilter file
Dim objFSO : Set objFSO = CreateObject("Scripting.FileSystemObject")
IF objFSO.FileExists(linklist) THEN
Dim objTextFile : Set objTextFile = objFSO.OpenTextFile(linklist, 1)
Dim strText : strText = objTextFile.ReadAll
Dim AdFile : Set AdFile = objFSO.OpenTextFile(adfilter, 8)
AdFile.WriteLine strText
AdFile.Close
ELSE 'wscript.echo "Sorry, the myfilter file does not exist"
END IF
set objFSO = nothing
end sub
function ReadFirstLines(fileName, numberOfLines)
const wChar = "§"
dim res
' open text file
dim fso : set fso = createobject ("scripting.filesystemobject")
dim ts : set ts = fso.OpenTextFile(fileName)
' read the first x lines
dim x
for x = 1 to numberOfLines
res = res & ts.ReadLine & wChar
next
ts.close
set ts = Nothing
set fso = Nothing
' format output string
if len(res) > 1 then
res = left(res, len(res) - 1)
res = replace(res, wChar, vbCrlf)
end if
ReadFirstLines = res
end function
как, уйти от полных путей в
const destination = "C:\Program Files\SRWare Iron\adblock.ini"
const myfilter = "C:\Program Files\SRWare Iron\myfilter.txt"
если:- скрипт, adblock.ini, myfilter.txt - лежат в одной папке?