Login | |
|
 |
RE: Pop-up blocker parsed in VB script? Can this be scr... - 12/27/2006 4:48:36 PM
|
|
 |
|
| |
TNO
Posts: 1397
Score: 16
Joined: 12/18/2004
From: thenewobjective.com
Status: online
|
Flicker? I think thats an issue with your computer's performace, not IE. I've never seen any flicker when a pop-up is being blocked. (I'm currently using Windows XP pro with a pentium 3 and 128 mb of RAM, and I don't see any flicker)
_____________________________
To iterate is human, to recurse divine. -- L. Peter Deutsch
|
|
| |
|
|
|
 |
RE: Pop-up blocker parsed in VB script? Can this be scr... - 12/29/2006 10:57:22 PM
|
|
 |
|
| |
TNO
Posts: 1397
Score: 16
Joined: 12/18/2004
From: thenewobjective.com
Status: online
|
Well, the short answer is no. The longer answer is yes, its possible but is pretty lengthy and complex and not guaranteed to work. My only theory to how it could be used is by using vbscript to obtain the source code of the website in question, parse it, and remove any window.open methods or target="_blank" attributes..this will slow your browsing time by ALOT. I suggest you upgrade to IE7 or use firefox if it bothers you alot. You could also install Google's popup blocker as an alternative. Besides it'll save you some work.
_____________________________
To iterate is human, to recurse divine. -- L. Peter Deutsch
|
|
| |
|
|
|
 |
RE: Pop-up blocker parsed in VB script? Can this be scr... - 12/30/2006 4:20:34 AM
|
|
 |
|
| |
AngieX
Posts: 6
Score: 0
Joined: 12/27/2006
Status: offline
|
Someone posted this code on Usenet and trying to figure out if this is bogus or could work. I am still not VB expert and don't know if this is rouge code or leght Can you see if this indeed would solve my problems and could be modified to be a universal pop-up blocker? It appears to want to look for something specific but not sure. What is going on in there? Thanks so much for your thoughts, assistance if you can! DOUBLE !!!!! Happy New Years! '1 'Known bug : don't do right click on an IE icon in the taskbar, it freezes Set J=CreateObject("Shell.Application") on error resume next Do WScript.Sleep 2000 if instr(ucase(wscript.fullname),"CSCRIPT") Then wscript.echo Now For L=0 to J.windows.count-1 With J.windows.item(L) If IsObject(.document.frames) Then If Not isObject(.document.frames.opener) Then Else .document.frames.close End if End If End With Next Loop ' 2 Dim gstrDataFile 'As String -- Name of text file containing bad window titles Dim strEngine 'As String -- Used to tell the user what program is running the wscript. gstrDataFile = FileNameLikeMine("txt") If Not CreateObject("Scripting.FileSystemObject").FileExists(gstrDataFile) Then String2File "----- Title Data File -----" & vbCrLf & "www.quellochevuoi" & vbCrLf & "about:blank" & vbCrLf, gstrDataFile strEngine = Wscript.FullName strEngine = Mid(strEngine, InstRrev(strEngine, "\") + 1) strEngine = Left(strEngine, Instr(strEngine, ".") - 1) strEngine = Ucase(Left(strEngine, 1)) & Lcase(Mid(strEngine, 2)) MsgBox " This script will run until system shutdown killing windows whose titles are found in the ""Title Data File"" at """ & gstrDataFile & """." & vbCrLf & vbCrLf & " If you need to stop this process, kill the """ & strEngine & """ program with the Windows Task Manager (Ctrl-Alt-Del). Alternatively, you can stop the program by deleting, renaming, or emptying the title data file." & vbCrLf & vbCrLf & " This dialog will only appear when there is no title data file." End If While True KillWindows Wscript.Sleep 500 Wend Sub KillWindows Dim wsh 'As WScript.Shell Dim fs 'As Scripting.FileSystemObject Dim ts 'As Scripting.TextStream Dim strData 'As String -- Entire contents of gstrDataFile Dim strTitle 'As String -- Just one bad window title Const ForReading = 1 Set fs = CreateObject("Scripting.FileSystemObject") Set wsh = CreateObject("WScript.Shell") On Error Resume Next Err.Clear Set ts = fs.OpenTextFile(gstrDataFile, ForReading, True) If Err.Number = 0 Then strData = ts.ReadAll If Err.Number = 0 Then 'Read all title lines in data string Do Until (Instr(strData, vbCrLf) = 0) strTitle = Left(strData, Instr(strData, vbCrLf) - 1) strData = Mid(strData, Instr(strData, vbCrLf) + 2) If strTitle <> "" Then If wsh.AppActivate(strTitle) Then wsh.SendKeys "%{F4}" WriteLog Now & " " & strTitle End If End If Loop 'Grab last bit in case there was no ending CrLf strTitle = strData If strTitle <> "" Then If wsh.AppActivate(strTitle) Then wsh.SendKeys "%{F4}" WriteLog Now & " " & strTitle End If End If Else ts.Close Wscript.Quit 1 End If Else Wscript.Quit 1 End If ts.Close End Sub Sub WriteLog(strText) 'Write to screen if script is run with CSCRIPT. Otherwise, write to a log file. Dim fs 'As Scripting.FileSystemObject Dim ts 'As Scripting.TextStream Const ForAppending = 8 If Lcase(Right(Wscript.FullName, 11)) = "cscript.exe" Then Wscript.Echo strText Else Set fs = CreateObject("Scripting.FileSystemObject") Set ts = fs.OpenTextFile(Left(Wscript.ScriptFullName, InstrRev(Wscript.ScriptFullName, ".")) & "log", ForAppending, True) ts.WriteLine strText ts.Close End If End Sub Function FileNameLikeMine(strFileExtension) 'As String 'Returns a file name the same as the script name except 'for the file extension. Dim fs 'As Object Dim strExtension 'As String Set fs = CreateObject("Scripting.FileSystemObject") strExtension = strFileExtension If Len(strExtension) < 1 Then strExtension = "txt" If strExtension = "." Then strExtension = "txt" If Left(strExtension,1) = "." Then strExtension = Mid(strExtension, 2) FileNameLikeMine = Left(Wscript.ScriptFullName, InstrRev(Wscript.ScriptFullName, ".")) & strExtension End Function Sub String2File(strData, strFileName) 'Writes a string to a file Dim fs 'As Scripting.FileSystemObject Dim ts 'As Scripting.TextStream Const ForWriting = 2 Set fs = Wscript.CreateObject("Scripting.FileSystemObject") Set ts = fs.OpenTextFile(strFileName, ForWriting, True) ts.Write(strData) ts.Close End Sub
< Message edited by AngieX -- 12/30/2006 5:16:26 AM >
|
|
| |
|
|
|
 |
RE: Pop-up blocker parsed in VB script? Can this be scr... - 12/30/2006 5:23:06 AM
|
|
 |
|
| |
dm_4ever
Posts: 2722
Score: 46
Joined: 6/29/2006
From: Orange County, California
Status: offline
|
The second example seems to be reading a text file with window titles. The script then looks at any open windows that have a title matching any in the text file and closing the window with any of those titles. I'm not too sure about the first example.
_____________________________
dm_4ever My philosophy: K.I.S.S - Keep It Simple Stupid Read Me: http://www.visualbasicscript.com/m_24727/tm.htm Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm
|
|
| |
|
|
|
 |
RE: Pop-up blocker parsed in VB script? Can this be scr... - 12/30/2006 6:42:01 AM
|
|
 |
|
| |
TNO
Posts: 1397
Score: 16
Joined: 12/18/2004
From: thenewobjective.com
Status: online
|
This script will result in some real slow performance. It will also do make a "flicker" worse than the normal pop-up blocker. (only checks twice a second). Since it uses SendKeys to send Alt+F4, there is a good chance that it could miss and close windows you wouldn't want closed (like the browser itself). There is a significant number of websites that use PopUnder windows to get around stuff similar to this very thing. Its seriously best to use the inherent popup blockers already available in the browser. (Or the add-on toolbars from google or yahoo). Imagine if you were trying to use or create a website that requires the use of a popup, it would close almost immediately everytime you opened it. This is honestly in my opinion a very dirty script and I wouldn;t suggest anyone use it as a replacement for the already existing technologies for this problem; VBScript cannot compete in this regard. The ONLY way I would suggest a hand-made pop-up blocker is if you embedded an instance of the internet explorer object inside another application as an activeX control (Which is highly unnecessary I believe in the first place in comparison to alternatives)
_____________________________
To iterate is human, to recurse divine. -- L. Peter Deutsch
|
|
| |
|
|
|
|
|