Applescript To Close Most Tabs

I wrote this script in effort to have an applescript close all windows with more than one exception.  For example, if I had 10 tabs open, I may want it to only leave three critical work tabs open.
This script works to close all but the link shown.  I have not figured out how to get it to work on more than one tab.
Any suggestions would be appreciated.
tell application "Google Chrome"
          set windowList to every tab of every window whose URL does not start with "https://mail.google.com"
          repeat with tabList in windowList
                    set tabList to tabList as any
                    repeat with tabItr in tabList
                              set tabItr to tabItr as any
  delete tabItr
                    end repeat
          end repeat
end tell

Try this:
tell application "Google Chrome"
    set windowList to every tab of every window whose URL does not start with "https://mail.google.com"
    repeat with tabList in windowList
        repeat with thisTab in tabList
            close thisTab
        end repeat
    end repeat
end tell

Similar Messages

  • How to get AppleScript to close a specific tab in Safari?

    I want to use AppleScript to close a tab in Safari.
    My scipt opens when my computer turns on, opens Safari, opens a new tab, goes to my schools website and automatically logs me into their internet.
    After that, I want it to close the tab that it just did all that in. How can I do this? I don't want to close all tabs, just the current tab. This is what I have so far...
    tell application "Safari" to activate
    tell application "System Events"
              tell application "Safari"
                        open location "URL goes here"
      delay 5
                        tell application "System Events"
      keystroke return
                        end tell
              end tell
    end tell
    What code do I need to add to close this tab?
    Thanks!

    Nevermind. I figured it all out. Now, this will open Safari, log me into the schools internet, close the corresponding tabs, and minimize Safari.
    tell application "Safari" to activate
    tell application "System Events"
              tell application "Safari"
      delay 5
                        open location "URL goes here"
      delay 2
                        tell application "System Events"
      keystroke return
                        end tell
                        delay 0.25
                        set winlist to count of every window
                        repeat with i from 1 to winlist
                                  close (every tab of window i whose name = "webassign")
                                  close (every tab of window i whose name = "user identification portal")
                        end repeat
                        set miniaturized of window 1 to true
              end tell
    end tell

  • I cannot close the left most tab

    When I try to close the left most tab or the default tab at start-up, it won't close, even when I have other tabs opened.

    Other things that need attention.<br>
    See http://www.mozilla.com/plugincheck/
    Your above posted system details show outdated plugin(s) with known security and stability risks that you should update.
    # Shockwave Flash 10.0 r32
    # Next Generation Java Plug-in 1.6.0_21 for Mozilla browsers
    Update the [[Managing the Flash plugin|Flash]] plugin to the latest version.
    *http://www.adobe.com/software/flash/about/
    Update the [[Java]] plugin to the latest version.
    *http://www.oracle.com/technetwork/java/javase/downloads/index.html (Java Platform: Download JRE)

  • Bug - If more then one tab is open and you try to swap tabs or close a tab Firefox closes completely sometimes. This happens on a desktop and 2 laptops I own.

    The first time I reported this was Jul 12. The link back did not work. Since Jul 12 I have been on my daughters desktop, my girlfriends desktop, my laptop and desktop and they will all do the same thing periodically. When more than one tab is open and you try to swap or close a tab Firefox closes completely.
    When I re-open Firefox I never get an error message to report back to Firefox support. Most of the time I get the "This is embarrassing" message and the restore tabs works.
    I should have been reported by other people. Please respond, I will check my email a few times a day, Thank you

    (previous message was https://support.mozilla.com/en-US/questions/849469
    you are supposed to update that message for more help, likely no one has an answer).
    If it were the last tab not multiple tabs then it would have been:
    If you only had one tab open and id not always show the tab strip, that you would close the tab bar.
    Tools > Options > Tabs > [x] Always show the tab bar
    Make sure you have that option on, it is easy to restore a tab if you still have the tab bar you or something closes two tabs as you say. To restore last tab use Ctrl+Shift+T , if two tabs restore that tab as well with same shortcut. Rather than fishing around for it in the History menu as a closed tab, closed window, or a previous session.
    Another possibility is that if there is one extension that mixed up the options like "Close Tab by Double Click" there are probably other extensions that did that as well. If you had that you might have to use the much larger "Tab Clicking Options" and turn off everything but closing a tab on double-click.
    : https://addons.mozilla.org/en-US/firefox/addon/tab-clicking-options/
    : which is not updated for Firefox 5.0, so you would have to override compatibility (it works) with
    * https://addons.mozilla.org/en-US/firefox/addon/add-on-compatibility-reporter/
    You can make Firefox '''Firefox 5.0''' look like Firefox 3.6.19, see numbered items 1-10 in the following topic [http://dmcritchie.mvps.org/firefox/firefox-problems.htm#fx4interface Fix Firefox 4.0 toolbar user interface, problems (Make Firefox 5.0, or 4.0.1, look like 3.6)]. ''Whether or not you make changes, you should be aware of what has changed and what you have to do to use changed or missing features.''

  • Why DOESN'T Firefox VERSION 6.0.2 warn me when "You are about to close multiple tabs. Do you want to continue"? aka "Confirm Close".

    Hello. I have a Windows 7 HP Mini Netbook 32-bit. I just installed Firefox version 6.0.2 (the most updated one). Under
    Tools ---> Options ---> Tabs, "Warn me when closing multiple tabs" is checked. However, when I have multiple tabs open and I click on "X" (accidentally one time), it closed Firefox. No warning at all. I tested it again and again (checking the box, unchecking it, then checking it again), and it keeps closing all my tabs without warning.
    FYI...I also have a work laptop (Windows XP) and for some reason the "Confirm close" shows up when I try to close multiple tabs.
    Thank you.

    Firefox does not ask to save tabs and windows on exit
    * https://support.mozilla.com/en-US/kb/Firefox%20does%20not%20ask%20to%20save%20tabs%20and%20windows%20on%20exit
    Warning does not appear when closing multiple tabs
    * http://kb.mozillazine.org/Warning_does_not_appear_when_closing_multiple_tabs
    Check and tell if its working.

  • Firefox crashes when I close a tab containing a PDF file; I am running Firefox 3.6.16 on Windows 7 with Acrobat Professional 9.2.0.

    This happens systematically if I close a tab or attampt to display something else in the tab which is not a PDF file.

    News 1. Mozilla has told me that there will be a fix by the end of the month. 2. I have asked Mozilla to contact me as soon as the fix is available. 3. I will monitor Norton and Firefox from 08:00 to 17:00 CT and update this forum entry when the fix becomes available. 4. Because the most current release of Firefox is 18.0.1, most future updates will be done to forum entry
    [[https://support.mozilla.org/en-US/questions/947601]]

  • Close other tabs option freezes computer then tabs will not close at all

    When I have multiple tabs open and I click the close other tabs button The computer freezes for about 1 minute and when it is unfrozen all the tabs are still there and when you click to close them nothing happens. This is a daily happening and extremely annoying. Sometimes it happens after i have had the browser open for a while and other times it will do it as soon as i open it.

    Hey, these are the instructions on how to try safe mode. Please post back with your results.
    '''Try Firefox Safe Mode''' to see if the problem goes away. [[Troubleshoot Firefox issues using Safe Mode|Firefox Safe Mode]] is a troubleshooting mode that turns off some settings, disables most add-ons (extensions and themes).
    If Firefox is open, you can restart in Firefox Safe Mode from the Help menu:
    *In Firefox 29.0 and above, click the menu button [[Image:New Fx Menu]], click Help [[Image:Help-29]] and select ''Restart with Add-ons Disabled''.
    *In previous Firefox versions, click on the Firefox button at the top left of the Firefox window and click on ''Help'' (or click on ''Help'' in the Menu bar, if you don't have a Firefox button) then click on ''Restart with Add-ons Disabled''.
    If Firefox is not running, you can start Firefox in Safe Mode as follows:
    * On Windows: Hold the '''Shift''' key when you open the Firefox desktop or Start menu shortcut.
    * On Mac: Hold the '''option''' key while starting Firefox.
    * On Linux: Quit Firefox, go to your Terminal and run ''firefox -safe-mode'' <br>(you may need to specify the Firefox installation path e.g. /usr/lib/firefox)
    When the Firefox Safe Mode window appears, select "Start in Safe Mode".<br>
    [[Image:Safe Mode Fx 15 - Win]]
    '''''If the issue is not present in Firefox Safe Mode''''', your problem is probably caused by an extension, and you need to figure out which one. Please follow the [[Troubleshoot extensions, themes and hardware acceleration issues to solve common Firefox problems]] article to find the cause.
    ''To exit Firefox Safe Mode, just close Firefox and wait a few seconds before opening Firefox for normal use again.''
    When you figure out what's causing your issues, please let us know. It might help others with the same problem.

  • Multible tabs open when i clik a link to a new tab; then do not open or even show up when i try to close them with 'close all tabs'..they are like 'ghost tabs'

    This has been happening for several days now...the tabs are shown on the tab bar, but do not open up or close when i try to close them....when i tried 'close all tabs', which then says 'you are trying to close 2 tabs', they are not counted as being open....only way i can get rid of them is to close FireFox completely, then it starts all over again. Ghost Tabs!

    Hello,
    '''Try Firefox Safe Mode''' to see if the problem goes away. [[Troubleshoot Firefox issues using Safe Mode|Firefox Safe Mode]] is a troubleshooting mode that turns off some settings, disables most add-ons (extensions and themes).
    If Firefox is open, you can restart in Firefox Safe Mode from the Help menu:
    * Click the menu button [[Image:New Fx Menu]], click Help [[Image:Help-29]] and select ''Restart with Add-ons Disabled''.
    If Firefox is not running, you can start Firefox in Safe Mode as follows:
    * On Windows: Hold the '''Shift''' key when you open the Firefox desktop or Start menu shortcut.
    When the Firefox Safe Mode window appears, select "Start in Safe Mode".<br>
    [[Image:Safe Mode Fx 15 - Win]]
    '''''If the issue is not present in Firefox Safe Mode''''', your problem is probably caused by an extension, and you need to figure out which one. Please follow the [[Troubleshoot extensions, themes and hardware acceleration issues to solve common Firefox problems]] article to find the cause.
    ''To exit Firefox Safe Mode, just close Firefox and wait a few seconds before opening Firefox for normal use again.''
    When you figure out what's causing your issues, please let us know. It might help others with the same problem.

  • Why can i not close a tab after i have 2 showing the only why 2 leave that site is 2 exit all tabs and restart firefox

    why can i not close a tab i have 2 close all tabs and restart firefox then selet browse this is verry anoying

    Try the Firefox SafeMode to see how it works there. <br />
    ''A troubleshooting mode, which disables most Add-ons.'' <br />
    ''(If you're not using it, switch to the Default Theme.)''
    * You can open the Firefox 4/5/6/7 SafeMode by holding the '''Shft''' key when you use the Firefox desktop or Start menu shortcut.
    * Or use the Help menu item, click on '''Restart with Add-ons Disabled...''' while Firefox is running. <br />
    ''Don't select anything right now, just use "Continue in SafeMode."''
    ''To exit the Firefox Safe Mode, just close Firefox and wait a few seconds before using the Firefox shortcut (without the Shft key) to open it again.''
    If it is good in the Firefox SafeMode, your problem is probably caused by an extension, and you need to figure out which one. <br />
    http://support.mozilla.com/en-US/kb/troubleshooting+extensions+and+themes

  • How to close a tab(s) in Safari 5 (10.8)

    My friend just updated to 10.8 and she noticed that there is no more X to close tabs now. I have not installed 10.8 yet because I always wait untile 10.x.1 to come out to fix most glitches.
    I did some research and came across this: "Anyone who has a nasty habit of having too many tabs open will love Safari's new Tab View. Pinch to zoom out and you'll see all of your tabs laid out horizontally; swipe with two fingers to move from one to the next, and click on the one you want to open or click on the X to close it. We'd like to see Apple add a two-finger swipe up to close tabs in this view."
    But there is no way in **** Apple went and did that. And even right clicking on the tab and selecting close is illogical..
    So where is the X to simply close a tab now.
    Thanks for the info guys.
    Screenshot enclosed:

    ya I'm aware of the shortcut keys. Been using a mac since they came out. She is used to interaction with the mouse, hence the specific question as to where the X has gone.

  • How do I stop Firefox from crashing everytime I close a tab?

    Ever since I downloaded Firefox 4.0, it crashes anytime I close a tab or a window.

    Hello,
    '''Try Firefox Safe Mode''' to see if the problem goes away. Safe Mode is a troubleshooting mode, which disables most add-ons.
    ''(If you're not using it, switch to the Default theme.)''
    * On Windows you can open Firefox 4.0+ in Safe Mode by holding the '''Shift''' key when you open the Firefox desktop or Start menu shortcut.
    * On Mac you can open Firefox 4.0+ in Safe Mode by holding the '''option''' key while starting Firefox.
    * On Linux you can open Firefox 4.0+ in Safe Mode by quitting Firefox and then going to your Terminal and running: firefox -safe-mode (you may need to specify the Firefox installation path e.g. /usr/lib/firefox)
    * Or open the Help menu and click on the '''Restart with Add-ons Disabled...''' menu item while Firefox is running.
    [[Image:FirefoxSafeMode|width=520]]
    ''Once you get the pop-up, just select "'Start in Safe Mode"''
    [[Image:Safe Mode Fx 15 - Win]]
    '''''If the issue is not present in Firefox Safe Mode''''', your problem is probably caused by an extension, and you need to figure out which one. Please follow the [[Troubleshooting extensions and themes]] article for that.
    ''To exit the Firefox Safe Mode, just close Firefox and wait a few seconds before opening Firefox for normal use again.''
    ''When you figure out what's causing your issues, please let us know. It might help other users who have the same problem.''
    Thank you.

  • Firefox crashes when I close a tab

    Frequently, but not always Firefox will crash when I close a tab. I might have 3 - 7 tabs open and I can move between them or refresh one without a problem but if I click on the 'X' to close the tab I get a message saying firefox has stopped working. When I restart I am asked if I want to restore. If I do I can close the tab I was trying to close earlier without a problem.
    I am running Vista Home Premium - completely up to date on a QC50 laptop This isn't happening on my Win 7 desktop. Firefox & all extensions are up to date (this didn't start happening until I updated to 5.0.1)

    News 1. Mozilla has told me that there will be a fix by the end of the month. 2. I have asked Mozilla to contact me as soon as the fix is available. 3. I will monitor Norton and Firefox from 08:00 to 17:00 CT and update this forum entry when the fix becomes available. 4. Because the most current release of Firefox is 18.0.1, most future updates will be done to forum entry
    [[https://support.mozilla.org/en-US/questions/947601]]

  • Clinking on the X does not close the Tab

    Recently I had to run the Loaris Trojan remover to get rid of something that hijacked my home page and search engine. I also had to reset the Firefox defaults. Somewhere in there I lost the ability to close a Tab by clicking on the X. The X is there but it does no close the Tab when I click on it. The only way I can close Tabs is to completely Exit Firefox and relaunch.
    How do I restore closing Tabs?

    Did you try the '''safe mode''' option ?
    Safe Mode is a troubleshooting mode, which disables most add-ons.
    ''(If you're not using it, switch to the Default theme.)''
    * On Windows you can open Firefox 4.0+ in Safe Mode by holding the '''Shift''' key when you open the Firefox desktop or Start menu shortcut.
    * Or open the Help menu and click on the '''Restart with Add-ons Disabled...''' menu item while Firefox is running.
    [[Image:FirefoxSafeMode|width=520]]
    ''Once you get the pop-up, just select "'Start in Safe Mode"''
    [[Image:Safe Mode Fx 15 - Win]]
    '''''If the issue is not present in Firefox Safe Mode''''', your problem is probably caused by an extension, and you need to figure out which one. Please follow the [[Troubleshooting extensions and themes]] article for that.
    ''To exit the Firefox Safe Mode, just close Firefox and wait a few seconds before opening Firefox for normal use again.''
    Thank you.

  • How do I enable 'close all tabs' warning in Safari 5.1/Lion OS?

    Before upgrading to Lion OS, there was a warning asking to confirm close all tabs. Now the warning is gone and I would like it back. There is no setting in Preferences, Tabs to enable this warning. Thank you.

    Well, the plist key is ConfirmClosingMultiplePages in com.apple.Safari.plist.  Unfortunately, it is set to <true/> just like in 10.6 and it doesn't work.  It could be a bug, but given that is removed from the UI, they might have just dropped this feature and the key in the plist is just a leftover from 5.0.
    I've filed bug rdar://9844047 on it, we'll see if it gets closed.  I guess I just need to get out of the habit of using CMD-SHIFT-W.  Of course, the other thing I used it for was as a confirmation before quitting Safari in case I accidentally hit CMD-Q instead of CMD-W.  Although that isn't really the intended use case, that is what I miss the most (Reopen All Windows $ucks when you have a lot of them).
    (Really, I can't use the word s-u-c-k-s?)

  • Can I set Thunderbird to close all tabs when I shut it down so the next session starts fresh.

    I would prefer to have a clear work platform each time I start Thunderbird and only see tabs relevant to that session. If the program could be set to close all tabs automatically when I shut down, that would solve my problem.
    Thanks,
    Keith Marshall.

    I guess your best bet is to right-click the most left tab - 'Close Other Tabs' before shutting down Thunderbird.

Maybe you are looking for