Created
September 14, 2012 11:06
-
-
Save naoyeye/3721330 to your computer and use it in GitHub Desktop.
Awesome Screenshot > resouces > as-ff > lib > ui.js
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
function capture(option) { | |
var window = mediator.getMostRecentWindow("navigator:browser") | |
//为了在v2ex显示方便,这里加了个回车 | |
.gBrowser.contentWindow; | |
var document = window.document; | |
var html = document.documentElement; | |
var w, h, x, y; | |
switch(option) { | |
case 'visible': | |
x = 0; | |
y = html.scrollTop; | |
w = html.clientWidth; | |
h = html.clientHeight; | |
break; | |
case 'entire': | |
x = y = 0; | |
w = html.scrollWidth; | |
h = html.scrollHeight; | |
break; | |
case 'similar': | |
var url = mediator.getMostRecentWindow("navigator:browser") | |
//为了在v2ex显示方便,这里加了个回车 | |
.gBrowser.contentWindow.document.URL | |
tabs.open('http://www.similarsites.com/search? | |
//为了在v2ex显示方便,这里加了个回车 | |
searchURL='+encodeURIComponent(url)+'&ref=dg'); | |
break; | |
} | |
var canvas = document.createElement('canvas'); | |
canvas.width = w; | |
canvas.height = h; // need refinement | |
canvas.style.display = 'none'; | |
document.body.appendChild(canvas); | |
var ctx = canvas.getContext("2d"); | |
ctx.drawWindow(window, x, y, w, h, 'rgb(255, 255, 255)'); | |
captureData = { | |
data: canvas.toDataURL(), | |
taburl: window.location.href, | |
tabtitle: document.title, | |
w: w, h:h | |
}; | |
tabs.open({url: data.url('edit.html')}); | |
} | |
function getCaptureData() { | |
return captureData; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment