Jump to content

Popup blocker for firefox


goldenix
 Share

Recommended Posts

Tag : Popup blocker / Pop-up blocker

So my Firefox does not block those popups anymore, in fact it opens them in totally new window, even despite the fact its configured to open links in new tab.

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.2.11.1 (beta)
 Author:         goldenix

 Script Function:
 
 How to use? just start firefox & run the code.
    
    1) get main handle
    2) if blacklisted window exists get its handle & Winclose
    3) blacklisted window names are inside pop_adress.txt (last line must be empty)
    4) $loopspeed = how fast it should check for blacklisted windows (speed 10 should me minimum)
    
Remarks:
    
    [Mozilla Firefox] dont remove this entry from pop_adress.txt it must be there,
    because first window is always named [Mozilla Firefox] & it will navigate to 
    
    $var[$i][0]
    -> [$i]=array column1
    -> [0]=array column2
    
    See WinList() finction for original gethandles code
#ce ----------------------------------------------------------------------------

;~      MsgBox(0, "Details", "Title=" & $var[$i][0] & @LF & "Handle=" & $var[$i][1])
    
;~ #cs ----------------------------------------------------------------------------
    
Opt("WinTitleMatchMode", 4)     ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase

Global $mainFox_handle, $line

_main()
Func _main()
While 1 
    Sleep(30000) ; wait 30 sec before start blocking popups
    If ProcessExists('firefox.exe') Then
        Sleep(5000)
        _sub_main()
    Else
        ProcessWait('firefox.exe')
    EndIf       
WEnd
EndFunc

Func _sub_main()
    
    $loopspeed = 50

    $var = WinList()
    For $i = 1 to $var[0][0]
        If StringInStr($var[$i][0],'Mozilla Firefox') Then      ;get main window handle ( the one we do not want to close )
            $mainFox_handle = $var[$i][1]
        EndIf
    Next


        $file = FileOpen("pop_adress.txt", 0)
        
            If $file = -1 Then ; Check if file opened for reading OK
                MsgBox(0, "Error", "Unable to open file.")
                Exit
            EndIf

            ; Read in lines of text until the EOF is reached
            For $a = 1 To 1000000000000000 
                
                If ProcessExists('firefox.exe') Then
                    
                    Sleep($loopspeed)
                    $line = FileReadLine($file,$a )                 
                        If @error = -1 Then
                            $a = 0 ; $a= because lat line of the file must be empty
                        Else
                            if WinExists($line) Then _gethandle2()                                  
                        EndIf
                Else
                    _main()
                EndIf
            Next

        FileClose($file)
EndFunc


Func _gethandle2()
;get second window handle ( the one we want to close )  
    $var = WinList()
    For $i = 1 to $var[0][0]
        If StringInStr($var[$i][0],'Mozilla Firefox') And $var[$i][1] <> $mainFox_handle Then
            $handle2 = $var[$i][1]
            
            WinClose($handle2)
                
;~          Beep(8000, 100)
        EndIf
    Next
EndFunc

pop_adress.txt

Edited by goldenix
My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list]
Link to comment
Share on other sites

k i added some code, so now it should work even if you restart firefox. ( just run the code & it works 24/7 now )

& if you need so badly to open something in new window just pause the script by clicking on the autoit icon in the right bottom of the screen. (yes there is no other way, because firefox always first opens blank page & then navigates from it & this also applies to popups.)

Edited by goldenix
My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list]
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...