Created
November 12, 2014 07:38
-
-
Save Infocatcher/9d6b5743298b19309a0d to your computer and use it in GitHub Desktop.
Open tab in Firefox with scroll and zoom (but zoom works strange with browser.zoom.siteSpecific = true)
This file contains 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
var textZoom = 1.5; | |
var fullZoom = 1; | |
var scrollX = 0; | |
var scrollY = 200; | |
var tab = gBrowser.addTab("https://addons.mozilla.org/"); | |
var browser = tab.linkedBrowser; | |
if(scrollX || scrollY) { | |
var scrollTimer = setInterval(function() { | |
var win = browser.contentWindow; | |
win.scrollTo(scrollX, scrollY); | |
if(win.scrollX == scrollX && win.scrollY == scrollY) { | |
clearInterval(scrollTimer); | |
scrollTimer = 0; | |
browser.removeEventListener("load", onLoad, true); | |
} | |
}, 50); | |
var onLoad = function(e) { | |
browser.removeEventListener("load", onLoad, true); | |
if(scrollTimer) { | |
clearInterval(scrollTimer); | |
scrollTimer = 0; | |
} | |
browser.contentWindow.scrollTo(scrollX, scrollY); | |
}; | |
browser.addEventListener("load", onLoad, true); | |
} | |
if(textZoom != 1 || fullZoom != 1) { | |
// Note: correctly works only with browser.zoom.siteSpecific = false | |
var viewer = browser.markupDocumentViewer; | |
viewer.textZoom = textZoom; | |
viewer.fullZoom = fullZoom; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment