From f13b16d94b29668e25cc953509852378410490bb Mon Sep 17 00:00:00 2001 From: MatMoul Date: Thu, 5 Oct 2017 21:31:15 +0200 Subject: [PATCH] Version 0.0.2 --- makerelease | 2 +- src/js/background.js | 25 ++++++++++++++++++++++++- src/manifest.json | 2 +- 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/makerelease b/makerelease index 4f5f33e..fc4ae6d 100755 --- a/makerelease +++ b/makerelease @@ -35,7 +35,7 @@ version=$1 sed -i "/\"version\":/c\ \ \"version\": \"$version\"," src/manifest.json -git commit -m "Version $version" makefile src/* +git commit -a -m "Version $version" git push git checkout master diff --git a/src/js/background.js b/src/js/background.js index 64db6a8..dd7cf5b 100644 --- a/src/js/background.js +++ b/src/js/background.js @@ -125,7 +125,7 @@ core.SiteInfos.fromTab = function(callback){ // Retrieve infos from current tab. setTimeout(whaitLoaded, 300); }, function(){ if(callback) callback(); }); } -core.SiteInfos.fromNewTab = function(url, callback){ // Retrieve infos from a new tab. callback( { url, title, icon, screenshot } || error: callback() ) +core.SiteInfos.fromNewTab1 = function(url, callback){ // Retrieve infos from a new tab. callback( { url, title, icon, screenshot } || error: callback() ) browser.tabs.create({url: url, active: false}).then(function(tab){ browser.tabs.update(tab.id, {muted: true}).then(); function whaitLoaded(){ @@ -133,9 +133,32 @@ core.SiteInfos.fromNewTab = function(url, callback){ // Retrieve infos from a n if(tab.status == 'loading') setTimeout(whaitLoaded, 300); else { browser.tabs.update(tab.id, {active: true}).then(function(){ +console.log('Hello'); setTimeout(function(){ browser.tabs.captureVisibleTab().then(function(img){ browser.tabs.remove(tab.id); + + var previewWidth = 1200; // Need to be linked to settings + var previewHeight = 710; // Need to be linked to settings + var imgObj = new Image; + imgObj.src = img; + + var canvas = document.createElement('canvas'); + canvas.style.width = previewWidth.toString() + 'px'; + canvas.style.height = previewHeight.toString() + 'px'; + canvas.width = previewWidth / 2; + canvas.height = previewHeight / 2; + var ctx = canvas.getContext('2d'); + ctx.clearRect(0, 0, previewWidth, previewHeight); + ctx.save(); + ctx.scale(0.5, 0.5); + //ctx.drawImage(img, 0, 0, previewWidth, previewHeight, 'rgb(255, 255, 255)'); +console.log(img); + ctx.drawImage(imgObj, 0, 0, 0, 0, 'rgb(255, 255, 255)'); + ctx.restore(); + img = canvas.toDataURL(); + + if(callback) callback( { url: tab.url, title: tab.title, icon: tab.favIconUrl, screenshot: img } ); }, function(){ browser.tabs.remove(tab.id); diff --git a/src/manifest.json b/src/manifest.json index 94728d6..2cc89c6 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -2,7 +2,7 @@ "manifest_version": 2, "name": "Quick Dial", - "version": "0.0.1", + "version": "0.0.2", "author": "MatMoul", "homepage_url": "https://github.com/MatMoul/quickdial-webext", "developer": {