Created
December 9, 2011 07:15
-
-
Save 958/1450591 to your computer and use it in GitHub Desktop.
[keysnail]特定URLを開いた際にのタブを自動でピン留めする
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//以下を .keysnail.js の PRESERVE エリアへ | |
// ここにURLを正規表現で指定する | |
plugins.options['autopin.pin_urls'] = [ | |
'^http://www\\.google\\.com/reader/view/', | |
'^https?://mail\\.google\\.com/mail/', | |
'^http://www\\.tumblr\\.com/dashboard', | |
]; | |
if (typeof (gBrowser) != 'undefined') { | |
// http://stackoverflow.com/questions/3374056/firefox-gbrowser-getbrowserfortab-but-no-gbrowser-gettabforbrowser | |
function getTabForBrowser(aBrowser) { | |
for (var i=0; i<gBrowser.browsers.length; i++) { | |
if (gBrowser.getBrowserAtIndex(i) === aBrowser) | |
return gBrowser.tabContainer.getItemAtIndex(i); | |
} | |
return null; | |
} | |
if (my.autoPinProgressListener) | |
gBrowser.removeTabsProgressListener(my.autoPinProgressListener); | |
let pinURLs = plugins.options['autopin.pin_urls']; | |
my.autoPinProgressListener = { | |
onLocationChange:function(aBrowser, aProgress, aRequest, aURI) { | |
if (!aURI || !aURI.spec) return; | |
let tab = getTabForBrowser(aBrowser); | |
if (!tab.pinned) { | |
let aURL = aURI.spec; | |
for each (let url in pinURLs) | |
if (aURL.match(url)) | |
gBrowser.pinTab(tab); | |
} | |
}, | |
onStateChange:function() { }, | |
onProgressChange:function() { }, | |
onStatusChange:function() { }, | |
onSecurityChange:function() { }, | |
onLinkIconAvailable:function() { } | |
}; | |
gBrowser.addTabsProgressListener(my.autoPinProgressListener); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment