Detect tab restore event - google-chrome-extension

I have a Chrome extension that needs to distinguish between when a new tab is created (e.g. Ctrl+T or Open link in new tab) and when a recently-closed tab is restored (e.g. Ctrl+Shift+T or Recently closed). All of these actions trigger chrome.tabs.onCreated, but none of the properties in the tab parameter tell me whether this is a new tab or a restored tab. I was hoping that the commands API would allow me to detect when Ctrl+Shift+T is pressed to restore a closed tab, but it seems it's only for overwriting shortcuts and usable for detecting window management keypresses.
Currently I'm checking tab.pendingUrl !== "chrome://newtab/", but this treats opening a link in a new tab as though it was restoring a tab, which is not the correct behavior. Is there any way a Chrome extension can detect whether a tab is being newly created or restored?

Related

How to keep extension pop up to remain open when new tab is clicked

my extension close when link in the extension is clicked
How to keep extension pop up to remain open when new tab is clicked
In general, that's not possible as stated in Chrome Extensions FAQ:
Can extensions keep popups open after the user clicks away from them?
No, popups automatically close when the user focuses on some portion of the browser outside of the popup. There is no way to keep the popup open after the user has clicked away.
However, if you inspect the popup, it will stay open as long as you don't close the Developer Tools window.
For end users, the only thing you could do is use a tab instead of a popup if that works better for your use case, or just inject your code into a specific tab to show your interface on top of/next to a page, as some extensions like Siteimprove do.

Sharepoint Open Page in New Tab not Window

I am working on a sharepoint page and want certain links to open in a new tab not a new window. I haven't seen any way to do this other than have server access or doing some invasive coding. I'm not sure of actual version of SP but think it's 2007.
IE version is v8
I checked code in edit mode and can see the target blank bit but as I said it opens in new window not tab.
Thanks
Andrew
_blank option for target param instructs the browser to open hyperlink in either new tab or window. But it depends on browser config or how link has been clicked on (middle click, ctrl+click or normal click) how the link would be opened (new window or new tab).

TFS Pending Changes keyboard commands in VS2012

I'm using VS2012 with TFS2010 (which may or may not matter).
I cannot seem to get any of the keyboard commands that should work with the Pending Changes window to, y'know, work.
I've tried the steps listed here, and I've tried binding keys to ever "CompareWith" commands listed in the keyboard dialog. The only ones that actually seem to do anything are the File.* commands, but those operate on the open file, and not the Pending Changes window.
I've seen that commands like Alt-I (check-in) work, but they don't appear in the Keyboard settings.
Does the new window in VS2012 have its own set of keyboard settings that are set somewhere else? I'm trying to get to the point of have an keyboard-only workflow for Comparing, the Excluding or Undoing.
Update:
This is really strange. I can actually see the shortcut keys in the right-click dialog, but pressing them does nothing. I then tried changing it to a chord, and I get the error message: "The key combination (Ctrl+Shift+Q, Ctrl+Shift+Q) is bound to command (Tfs.ContextPendingChangesPageExcludeChanges) which is not currently available"
Update 2: I found this blog post, which has some more shortcuts listed, but not that actually do operations on the individual files. For quick reference, here's his list:
Shortcut Team Explorer Page
Ctrl+' Search
Ctrl+0,H Home
Ctrl+0,P Pending Changes
Ctrl+0,M My Work
Ctrl+0,W Work Items
Ctrl+0,B Build
Ctrl+0,R Reports
Ctrl+0,D Documents
Ctrl+0,S Settings
Ctrl+0,A Web Access – team home page
F5 Refresh
Ctrl+Up Move focus to the previous visible section header
Ctrl+Down Move focus to the next visible section header
Alt+Left Navigate backward
Alt+Right Navigate forward
Alt+Home Focus the navigation control
Alt+0 Focus the page top level content
Alt+[1-9] Focus the visible section [1-9] level content
Alt+Up Focus the previous visible section content
Alt+Down Focus the next visible section content
There is a bug with key bindings in some Team Explorer pages in VS 2012 RTM. This has been fixed for the next VS 2012 update.
-Chad

Any way to remove X button from chrome tabs?

Is there any way to modify chrome tabs to remove the button that closes the tab?
I've read through chrome develope tab. but I don't see any mention of the close button.
Not possible at the moment without forking the whole chromium project. See bug report #50913 (Status: WontFix).
Possible workarounds:
If you right click on a tab you can Pin Tab. This will remove the close button but you can still close it with ctrl+w. Unfortunately, this will also remove the window title.
The close button is removed if the width of the tab gets very small.
Have a look at the same question on SuperUser: How to disable the close (X) button on Google Chrome tabs?.
Maybe you like to look at the source code of Chromium and fix this? I think you have to start here: tab.cc.
Edit: The fix below only worked between Chrome version 69 and 71.
It IS possible now for inactive tabs!
I have had lots of problems while trying to switch tab while having 10-15 of them opened, accidentally closing some important tab with lots of text typed which isn't recovered by Ctrl+Shift+T
Here how to do that:
1) Open the Google Chrome browser and type the following text into the address bar:
chrome://flags/#close-buttons-inactive-tabs
This will open the flags page directly with the relevant setting.
2) Set the option named Close buttons on inactive tabs. Set it to Disabled using the drop down list next to the flag's name.
3) Restart Google Chrome by closing it manually or you can also use the Relaunch button which will appear at the very bottom of the page.
4) The close buttons will disappear from inactive tabs.
Before:
After:
That's it!
Source - https://winaero.com/blog/remove-close-buttons-inactive-tabs-google-chrome/
There are now Chromium-based alternative browsers which offer this - I really like Vivaldi, where not showing the X button is just one of many customization options. Also, because it is Chromium based you can install and use any Chrome extensions. It is perfect if you have many tabs open and need more of the power-user type options.

Gmail does not obey browser settings for tabs

I noticed that Gmail is not obeying my browser settings for tabs.
For ex:
In Firefox3.6.10, I have unchecked the option "When I open a link in new tab switch to it immediately".
But still when I do CTRL+CLICK on a mail, it opens in a new tab and switches to it.
or
In IE8, I have selected "Always open pop-ups in a new window" but when I do CTRL+CLICK on a mail, it opens in a new tab instead of a new window.
My question is
Is it possible to override user's browser settings?
I was curious about how CTRL-click and SHIFT-click work on these gmail "fake JavaScript links" myself (they appear to ignore browser settings), so I did some testing.
gmail CTRL-click does obey browser "new window/popup" settings (in Firefox the default is "open in new tab", in IE8 the default seems to be "open in new window".) If you change IE8's settings to "Always open popups in a new tab", then you get the same behaviour as Firefox. So gmail CTRL-click is very likely just using "window.open()" in JavaScript, and it's really nothing special. I seriously doubt there's any way to force a new tab to open in JavaScript. Like Yonizaf said, what you observed doesn't seem possible.
gmail SHIFT-click probably uses this method to try to always open a new window (and never a new tab) in JavaScript (window.open() with window dimensions):
JavaScript open in a new window, not tab
As far as the focus thing goes, I noticed that in Firefox new gmail tabs always get the focus, regardless of the "when I open link in new tab, switch to it immediately" setting (like you said), but in IE8 the behaviour seems to be controlled by the "Always switch to new tabs when they are created" setting. I'm guessing this is probably just a result of how Firefox and IE's developers chose to handle new tabs that are created by window.open(), and there isn't much you can do about it, except as Yonizaf said, try to use the window.focus() method (I have a feeling it may not work in IE, though). In fact you can test this for yourself in Firefox and IE8 (disable your pop-up blocker first). I pasted the following URL into both Firefox and IE8 (with "Always switch to new tabs when they are created" disabled, and "Open popups in new tabs" enabled):
javascript:window.open("http://www.google.com", "_blank")
In Firefox, the new tab was opened in the foreground. In IE8, the new tab was opened in the background.
I don't like these JavaScript "fake links" personally, because you lose the middle-click and right-click functionality, and they trigger the pop-up blocker.
the first one is possible, since this options only meant to change the default behavior for links.
the mail list in gmail aren't normal links, it's using javascript.
for the second example, the option can't be overriden by the webpage, but using ctrl+click always means open in new tab, so it's overriden by the user, not the page.

Resources