mozilla:abpxfiles:vbs:stablemaker
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | Last revisionBoth sides next revision | ||
mozilla:abpxfiles:vbs:stablemaker [2013/11/09 19:40] – gfsadministrator | mozilla:abpxfiles:vbs:stablemaker [2013/12/27 14:44] – gfsadministrator | ||
---|---|---|---|
Line 10: | Line 10: | ||
Facendo clic sul nome dello script " | Facendo clic sul nome dello script " | ||
+ | |||
+ | <file vb Stable-Maker_0.2.vbs> | ||
+ | ' ABP X FILES Stable Maker 0.2 | ||
+ | ' GSolone - Ultima modifica: 24122013-1326 rev0 | ||
+ | ' | ||
+ | ' Lo script modifica la lista filtri esportata dall' | ||
+ | ' | ||
+ | ' STORICO MODIFICHE | ||
+ | ' 0.2 rev0- corregge il bug sullo sdoppiamento dei contenuti (Remove Empty Lines usava una variabile gi‡ piena e replicava ogni riga) | ||
+ | ' 0.1 rev0- stadio iniziale di sviluppo. | ||
+ | ' | ||
+ | ' Sviluppo: Giovanni F. -Gioxx- Solone (dev@gfsolone.com) | ||
+ | ' Testato su: Windows 7 Pro Sp1 | ||
+ | ' | ||
+ | ' Non toccare nulla oltre questa riga! | ||
+ | ' DO NOT touch anything below this line! | ||
+ | |||
+ | ' Variables and constants definition | ||
+ | Dim i, objFile, objFSO, strFile, strMsg | ||
+ | Dim objWMIService, | ||
+ | Const ForReading = 1, ForWriting = 2, ForAppending = 8 | ||
+ | |||
+ | ' Date and time | ||
+ | strComputer = " | ||
+ | Set objWMIService = GetObject(" | ||
+ | Set colItems = objWMIService.ExecQuery(" | ||
+ | For Each objItem in colItems | ||
+ | dtmLocalTime = objItem.LocalDateTime | ||
+ | dtmMonth = Mid(dtmLocalTime, | ||
+ | dtmDay = Mid(dtmLocalTime, | ||
+ | dtmYear = Left(dtmLocalTime, | ||
+ | dtmHour = Mid(dtmLocalTime, | ||
+ | dtmMinutes = Mid(dtmLocalTime, | ||
+ | dtmSeconds = Mid(dtmLocalTime, | ||
+ | Next | ||
+ | update = dtmYear & dtmMonth & dtmDay & dtmHour & dtmMinutes | ||
+ | lastmodified = dtmDay & " | ||
+ | ' DEBUG: show $datetime | ||
+ | ' | ||
+ | |||
+ | ' Expand Environment | ||
+ | ' Create const' | ||
+ | Dim WshS | ||
+ | Set WshS = WScript.CreateObject(" | ||
+ | Set objFSO = CreateObject(" | ||
+ | usrProfile = WshS.ExpandEnvironmentStrings(" | ||
+ | strFile = usrProfile & " | ||
+ | ' DEBUG: Message to prove my string contains the path to my profile | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | ' Staging filtri.txt is on my Desktop? | ||
+ | If objFSO.FileExists(strFile) Then | ||
+ | Else | ||
+ | | ||
+ | | ||
+ | End If | ||
+ | |||
+ | ' Remove line 1 to 2, default header of Adblock Plus export | ||
+ | For i = 1 To 2 | ||
+ | DeleteLine strFile, "", | ||
+ | Next | ||
+ | |||
+ | ' Add list header (ABP X Files Stable) | ||
+ | Set objFile = objFSO.OpenTextFile(strFile, | ||
+ | strContents = objFile.ReadAll | ||
+ | objFile.Close | ||
+ | |||
+ | strFirstLine = " | ||
+ | |||
+ | strNewContents = strFirstLine & vbCrLf & strContents | ||
+ | Set objFile = objFSO.OpenTextFile(strFile, | ||
+ | ' | ||
+ | objFile.Write strNewContents | ||
+ | objFile.Close | ||
+ | |||
+ | ' Remove empty lines at the end of file! | ||
+ | Set objFile = objFSO.OpenTextFile(strFile, | ||
+ | Do Until objFile.AtEndOfStream | ||
+ | strLine = objFile.Readline | ||
+ | strLine = Trim(strLine) | ||
+ | If Len(strLine) > 0 Then | ||
+ | strCleaned = strCleaned & strLine & vbCrLf | ||
+ | End If | ||
+ | Loop | ||
+ | objFile.Close | ||
+ | Set objFile = objFSO.OpenTextFile(strFile, | ||
+ | objFile.Write strCleaned | ||
+ | objFile.Close | ||
+ | |||
+ | ' Move updated X Files to Dropbox (and overwrite old file) | ||
+ | ' (from %UserProfile%\Desktop\filtri.txt to C: | ||
+ | ' DEBUG su folder temporanea | ||
+ | ' | ||
+ | strDropbox = " | ||
+ | If objFSO.FileExists(strFile) Then | ||
+ | | ||
+ | Else | ||
+ | | ||
+ | End If | ||
+ | |||
+ | ' Open the file (verification process) and delete " | ||
+ | ' DEBUG su file temporaneo | ||
+ | ' | ||
+ | strDropboxFile = " | ||
+ | CreateObject(" | ||
+ | objFSO.DeleteFile strFile, True | ||
+ | |||
+ | Sub Run(ByVal sFile) | ||
+ | ' Variables definition | ||
+ | Dim shell | ||
+ | Set shell = CreateObject( " | ||
+ | shell.Run Chr(34) & sFile & Chr(34), 1, false | ||
+ | Set shell = Nothing | ||
+ | End Sub | ||
+ | |||
+ | Sub DeleteLine(strFile, | ||
+ | 'Use strFile = " | ||
+ | 'Use strKey = "John Doe" | ||
+ | 'Use strKey = "" | ||
+ | 'Use LineNumber = " | ||
+ | 'Use LineNumber = " | ||
+ | 'Use CheckCase = " | ||
+ | 'Use CheckCase = " | ||
+ | Const ForReading=1: | ||
+ | Dim objFSO, | ||
+ | Set objFSO = CreateObject(" | ||
+ | Set objFile=objFSO.OpenTextFile(strFile, | ||
+ | Do Until objFile.AtEndOfStream | ||
+ | | ||
+ | If CheckCase=0 then strLineCase=ucase(strLine): | ||
+ | If LineNumber=objFile.Line-1 or LineNumber=0 then | ||
+ | If instr(strLine, | ||
+ | | ||
+ | Else | ||
+ | | ||
+ | End If | ||
+ | Else | ||
+ | strNewFile=strNewFile& | ||
+ | End If | ||
+ | Loop | ||
+ | objFile.Close | ||
+ | | ||
+ | Set objFile=objFSO.OpenTextFile(strFile, | ||
+ | objFile.Write strNewFile | ||
+ | objFile.Close | ||
+ | End Sub | ||
+ | </ | ||
+ | |||
+ | ===== Archivio versioni ===== | ||
<file vb Stable-Maker_0.1.vbs> | <file vb Stable-Maker_0.1.vbs> | ||
Line 157: | Line 307: | ||
End Sub | End Sub | ||
</ | </ | ||
- | |||
- | ===== Archivio versioni ===== | ||
- | |||
- | Non ci sono ancora vecchie versioni di questo script. |
mozilla/abpxfiles/vbs/stablemaker.txt · Last modified: 2017/01/30 10:34 by gfsadministrator