阅读:3659回复:10
挺好的一个扩展,求转制成userchromeJS脚本
Tab History :: Add-ons for Firefox
New tabs retain the session history of the originating tab. Links opened in a new tab won't have a blank history, but one that is populated from the "parent" tab. 这个扩展很小,作用是从Tab 1中键点出Tab 2的时候,Tab 2可以继承Tab 1的历史,也就是从Tab 2可以退回Tab 1的历史页面。 XPI解包后,js源代码为: // I should probably just intercept link events, but don't know how // without iterating over all the <a> elements. var TabHistory = { // copies history from one tab to another, via tab.browser.sessionHistory copyHistory : function(fromTab, newTab) { var fromHistory = getBrowser().getBrowserForTab(fromTab).sessionHistory; var toHistory = getBrowser().getBrowserForTab(newTab).sessionHistory; // needed to use addEntry toHistory.QueryInterface(Components.interfaces.nsISHistoryInternal); // copy oldHistory entries to newHistory, simulating a continued session for(var i = 0; i < (fromHistory.index + 1); ++i) { toHistory.addEntry(fromHistory.getEntryAtIndex(i, false), true); } }, init : function() { // when left-click opens new windows in tabs (TabMix doesn't need this) // Note: this calls addTab, but with a blank tab, which is kind of a pain in the ass. eval('nsBrowserAccess.prototype.openURI = ' + nsBrowserAccess.prototype.openURI.toString().replace( /(var newTab.*;)/, '$1\nTabHistory.copyHistory(' + 'gBrowser.selectedTab, newTab);')); // rewrite addTab to add history // Note: the (0 == sessionHistory.count) is to not execute copyHistory if the // previous eval statement was called, because it's already been executed. var tabbrowser = document.getElementById("content"); eval('tabbrowser.addTab = ' + tabbrowser.addTab.toString().replace(/(t.linkedBrowser = b;)/, "$1\n" + "if((0 == b.sessionHistory.count) && aReferrerURI && aReferrerURI.scheme != 'chrome') " + "TabHistory.copyHistory(this.selectedTab, t);\n")); } }; window.addEventListener("load", function() { TabHistory.init(); }, false); |
|
|
1楼#
发布于:2009-07-20 00:31
KMC最近疯狂迷恋userchrome.js啊
|
|
|
2楼#
发布于:2009-07-20 00:31
最后一行改成这样试试
TabHistory.init(); 没必要都弄成脚本嘛,才2K的扩展,直接装就是了,还能自动升级,看作者的意思,是代码还没完善 |
|
|
3楼#
发布于:2009-07-20 00:31
tmp扩展自带。
|
|
4楼#
发布于:2009-07-20 00:31
|
|
|
5楼#
发布于:2009-07-20 00:31
俺想问一下 大虾们是不现在都用userchromeJS取代油猴子了。
这个新的组织形式稳定性好吗? 看了mozest那个置顶帖 感觉有些凌乱 那些脚本们。 |
|
6楼#
发布于:2009-07-20 00:31
|
|
|
7楼#
发布于:2009-07-20 00:31
用 userchrome.js 操作浏览器介面的确很强,希望将来 mx3 也能够实现 (mx3 也是用 html 描绘介面)
|
|
|
8楼#
发布于:2009-07-20 00:31
脚本流啊。。。。。。。。。。
|
|
9楼#
发布于:2009-07-20 00:31
userchrome.JS 一直在用它,赞:)
|
|
10楼#
发布于:2009-07-20 00:31
呵呵,我是stylish流,,,不行的就用js,精简扩展。。。
|
|