1
0
mirror of https://github.com/MatMoul/quickdial-webext.git synced 2025-12-15 16:33:13 +00:00

10 Commits

Author SHA1 Message Date
0b59809758 Version 0.1.6 2017-11-03 21:21:12 +01:00
f387c3662f Feature: Add page up and page down to change page 2017-11-03 21:11:57 +01:00
dbbf5ff718 Feature: Add page up and page down to change page 2017-11-03 21:02:57 +01:00
33c227a5a4 Merge branch 'patch-1' of https://github.com/Alexey71/quickdial-webext into Alexey71-patch-1 2017-11-03 20:54:11 +01:00
351d043094 Improvement: Limit sync bookmark surcharge 2017-11-03 20:52:41 +01:00
Alexey
b99ee356f0 Add Russian string 2017-11-01 15:35:47 +03:00
340a84730e Merge pull request #22 from mrprobot/develop
add german translation
2017-10-26 21:10:41 +02:00
mrprobot
ddd57dd446 add german translation 2017-10-25 13:04:20 +02:00
mrprobot
4a510a1a86 add german translation 2017-10-25 12:55:37 +02:00
170b1a7dc6 Improvement: Add new capture method (Capture here) 2017-10-22 16:36:06 +02:00
7 changed files with 301 additions and 13 deletions

View File

@@ -0,0 +1,72 @@
{
"extensionDescription": {
"message": "Quick Dial, eine Schnellwahl-Seite inspiriert von Fast Dial.",
"description": "Description of the extension."
},
"menuAddToQuickDial": {
"message": "Zu Quick Dial hinzufügen",
"description": "Text of add bookmark menu item."
},
"menuNew": {
"message": "Neu",
"description": "Text of new menu item."
},
"menuNewBookmark": {
"message": "Lesezeichen",
"description": "Text of add bookmark menu item."
},
"AddBookmarkPrompt": {
"message": "Neue Lesezeichen URL eingeben:",
"description": "Text of the add bookmark prompt."
},
"menuNewFolder": {
"message": "Ordner",
"description": "Text of add folder menu item."
},
"AddFolderPrompt": {
"message": "Neuen Ordner Namen eingeben:",
"description": "Text of the add folder prompt."
},
"menuProperties": {
"message": "Bearbeiten",
"description": "Text of properties menu item."
},
"menuRefreshItem": {
"message": "Neu laden",
"description": "Text of refresh menu item."
},
"menuCaptureHere": {
"message": "Hier aufnehmen",
"description": "Text of capture here menu item."
},
"menuCapturePage": {
"message": "In einem neuen Tab aufnehmen",
"description": "Text of capture menu item."
},
"menuDeleteItem": {
"message": "Löschen",
"description": "Text of delete menu item."
},
"deleteItemConfimation": {
"message": "Löschen $1?",
"description": "Text of delete confirmation."
},
"menuSettings": {
"message": "Quick Dial Einstellungen",
"description": "Text of settings menu item."
}
}

View File

@@ -44,6 +44,11 @@
"description": "Text of refresh menu item."
},
"menuCaptureHere": {
"message": "Capture here",
"description": "Text of capture here menu item."
},
"menuCapturePage": {
"message": "Capture in a new tab",
"description": "Text of capture menu item."

View File

@@ -44,6 +44,11 @@
"description": "Text of refresh menu item."
},
"menuCaptureHere": {
"message": "Capturer ici",
"description": "Text of capture here menu item."
},
"menuCapturePage": {
"message": "Capturer dans un nouvel onglet",
"description": "Text of capture menu item."

View File

@@ -0,0 +1,72 @@
{
"extensionDescription": {
"message": "Quick Dial, вдохновление умершим расширением Fast Dial.",
"description": "Description of the extension."
},
"menuAddToQuickDial": {
"message": "Добавить в Quick Dial",
"description": "Text of add bookmark menu item."
},
"menuNew": {
"message": "Добавить",
"description": "Text of new menu item."
},
"menuNewBookmark": {
"message": "Закладку",
"description": "Text of add bookmark menu item."
},
"AddBookmarkPrompt": {
"message": "Введите URL-адрес новой закладки:",
"description": "Text of the add bookmark prompt."
},
"menuNewFolder": {
"message": "Папку",
"description": "Text of add folder menu item."
},
"AddFolderPrompt": {
"message": "Введите имя новой папки:",
"description": "Text of the add folder prompt."
},
"menuProperties": {
"message": "Свойства",
"description": "Text of properties menu item."
},
"menuRefreshItem": {
"message": "Обновить",
"description": "Text of refresh menu item."
},
"menuCaptureHere": {
"message": "Захватить здесь",
"description": "Text of capture here menu item."
},
"menuCapturePage": {
"message": "Захватить на новой вкладке",
"description": "Text of capture menu item."
},
"menuDeleteItem": {
"message": "Удалить",
"description": "Text of delete menu item."
},
"deleteItemConfimation": {
"message": "Удалить $1?",
"description": "Text of delete confirmation."
},
"menuSettings": {
"message": "Настройки Quick Dial",
"description": "Text of settings menu item."
}
}

View File

@@ -212,7 +212,7 @@ app.Bookmarks._onMoved = function(){ app.GridNodes.sync(app.node, app.settings.g
app.Bookmarks._onRemoved = function(){ app.GridNodes.sync(app.node, app.settings.grid.root, function(){ browser.runtime.sendMessage({ cmd: app.Messages.Commands.gridNodesLoaded }); }); }
app.Bookmarks.initListener = function(){ // (Called from app.init) (/!\ Need filter to root tree only) Init listener of bookmarks
browser.bookmarks.onCreated.addListener(app.Bookmarks._onCreated);
//browser.bookmarks.onChanged.addListener(app.Bookmarks._onChanged);
browser.bookmarks.onChanged.addListener(app.Bookmarks._onChanged);
browser.bookmarks.onMoved.addListener(app.Bookmarks._onMoved);
browser.bookmarks.onRemoved.addListener(app.Bookmarks._onRemoved);
}
@@ -359,6 +359,11 @@ app.GridNodes.GridNodeType = { // GridNodeType
bookmark: 2
}
app.GridNodes.sync = function(gridNode, rootPath, callback){ // Sync GridNodes with Bookmarks
if(app.GridNodes._syncing) {
app.GridNodes._needSync = true;
return;
}
app.GridNodes._syncing = true;
app.Bookmarks.load(rootPath, function(bookmarkItem){
function syncNode(gridNode, bookmarkItem){
gridNode.id = bookmarkItem.id;
@@ -414,8 +419,14 @@ app.GridNodes.sync = function(gridNode, rootPath, callback){ // Sync GridNodes w
}
syncNode(gridNode, bookmarkItem);
app.GridNodes.save();
if(callback) callback();
delete app.GridNodes._syncing;
if(app.GridNodes._needSync == true) {
delete app.GridNodes._needSync;
app.GridNodes.sync(gridNode, rootPath, callback);
} else {
app.GridNodes.save();
if(callback) callback();
}
});
}
app.GridNodes.save = function(callback){ // Save GridNodes

View File

@@ -2,7 +2,8 @@ var utils = {};
var app = {};
var dial = {
page: 1,
maxpage: 1
maxpage: 1,
capture: 0
};
document.addEventListener("DOMContentLoaded", function(event) {
@@ -11,24 +12,40 @@ document.addEventListener("DOMContentLoaded", function(event) {
dial.init();
});
window.onresize = function(){
window.addEventListener('resize', function(){
if(app && app.settings) dial.updateGridLayout();
}
window.onwheel = function(ev){
});
window.addEventListener('wheel', function(e){
if(app && app.settings){
if(ev.deltaY > 0){
if(e.deltaY > 0){
if(dial.page < dial.maxpage){
dial.page += 1;
dial.populateGrid();
}
} else if(ev.deltaY < 0){
} else if(e.deltaY < 0){
if(dial.page > 1){
dial.page -= 1;
dial.populateGrid();
}
}
}
}
});
window.addEventListener('keyup', function(e){
switch(e.key){
case 'PageDown':
if(dial.page < dial.maxpage){
dial.page += 1;
dial.populateGrid();
}
break;
case 'PageUp':
if(dial.page > 1){
dial.page -= 1;
dial.populateGrid();
}
break;
}
});
@@ -73,7 +90,7 @@ app.Messages.init = function(){
app.Messages.getSettings(app.Settings._changed);
break;
case app.Messages.Commands.gridNodesLoaded:
app.Messages.getNode(dial.path, app.GridNodes._changed);
if(dial.skipUpdate!=true) app.Messages.getNode(dial.path, app.GridNodes._changed);
break;
}
});
@@ -96,6 +113,9 @@ app.Messages.getNode = function(path, callback){
}
});
};
app.Messages.updateNode = function(id, value, callback){
browser.runtime.sendMessage({ cmd: app.Messages.Commands.updateNode, id: id, value: value }).then(callback);
};
app.Messages.setNodeIndex = function(index, newIndex, callback){
browser.runtime.sendMessage({ cmd: app.Messages.Commands.setNodeIndex, path: dial.path, index: index, newIndex: newIndex }).then(callback);
};
@@ -194,6 +214,12 @@ dial.initMenus = function(){
dial.refreshNode(dial._selectedItem);
};
dial.ItemMenuCaptureHere = document.createElement('menuitem');
dial.ItemMenuCaptureHere.label = browser.i18n.getMessage("menuCaptureHere");
dial.ItemMenuCaptureHere.onclick = function(){
dial.captureHere(dial._selectedItem);
};
dial.ItemMenuCapture = document.createElement('menuitem');
dial.ItemMenuCapture.label = browser.i18n.getMessage("menuCapturePage");
dial.ItemMenuCapture.onclick = function(){
@@ -214,6 +240,7 @@ dial.initMenus = function(){
dial.ItemMenu.appendChild(document.createElement('hr'));
dial.ItemMenu.appendChild(dial.ItemMenuProperties);
dial.ItemMenu.appendChild(dial.ItemMenuRefresh);
dial.ItemMenu.appendChild(dial.ItemMenuCaptureHere);
dial.ItemMenu.appendChild(dial.ItemMenuCapture);
dial.ItemMenu.appendChild(dial.ItemMenuDelete);
dial.ItemMenu.appendChild(document.createElement('hr'));
@@ -267,7 +294,19 @@ dial.initGrid = function(){
link.className = 'Empty';
link.appendChild(document.createElement('div'));
link.appendChild(document.createElement('div'));
link.onmousedown = function(){ dial._selectedItem = this; };
link.onmousedown = function(){
dial._selectedItem = this;
if(dial._selectedItem.Node){
switch(dial._selectedItem.Node.type){
case app.GridNodes.GridNodeType.folder:
dial.ItemMenuCaptureHere.hidden = true;
break;
case app.GridNodes.GridNodeType.bookmark:
dial.ItemMenuCaptureHere.hidden = false;
break;
}
}
};
function dragstart_handler(ev) {
if(!ev.target.Node){
@@ -430,6 +469,88 @@ dial.refreshNode = function(selectedItem){
selectedItem.childNodes[0].style.backgroundImage = app.settings.grid.loadingIcon;
app.Messages.refreshNode(selectedItem.Node.id);
}
dial.captureHere = function(selectedItem){
function headersReceived(e){
for (let i = e.responseHeaders.length - 1; i >= 0; i--) {
switch(e.responseHeaders[i].name.toLowerCase()){
case 'x-frame-options':
case 'frame-options':
case 'content-security-policy':
e.responseHeaders.splice(i, 1);
break;
}
}
return { responseHeaders: e.responseHeaders };
};
function pageLoaded(){
if(!iframe) return;
function clean(){
if(!iframe) return;
selectedItem.children[0].removeChild(iframe);
dial.capture -= 1;
if(dial.capture == 0){
browser.webRequest.onHeadersReceived.removeListener(headersReceived);
browser.tabs.update(tab.id, {muted: false}).then();
}
iframe = null;
}
setTimeout(function(){
browser.tabs.captureVisibleTab().then(function(img){
var imgObj = new Image;
imgObj.src = img;
var canvas = document.createElement('canvas');
canvas.style.width = rect.width.toString() + 'px';
canvas.style.height = rect.height.toString() + 'px';
canvas.width = rect.width;
canvas.height = rect.height;
var ctx = canvas.getContext('2d');
ctx.clearRect(0, 0, rect.width, rect.height);
ctx.save();
setTimeout(function(){
ctx.drawImage(imgObj, rect.left, rect.top, rect.width, rect.height, 0, 0, rect.width, rect.height);
ctx.restore();
img = canvas.toDataURL();
selectedItem.children[0].style.backgroundImage = 'url(' + img + ')';
clean();
app.Messages.updateNode(selectedItem.Node.id, { image: img }, function(){
setTimeout(function(){
if(dial.capture == 0) dial.skipUpdate = false;
}, 500);
});
}, 500);
}, clean);
}, 3000);
};
var tab = null;
var previewWidth = 1200; // Need to be linked to settings
var previewHeight = 710; // Need to be linked to settings
var iframe = document.createElement('iframe');
var rect = selectedItem.children[0].getBoundingClientRect();
browser.tabs.getCurrent().then(function(currentTab){
tab = currentTab;
var ratioX = previewWidth / selectedItem.children[0].offsetWidth;
var ratioY = previewHeight / selectedItem.children[0].offsetHeight;
iframe.style.width = ratioX * selectedItem.children[0].offsetWidth + 'px';
iframe.style.height = ratioY * selectedItem.children[0].offsetHeight + 'px';
iframe.style.position = 'absolute';
iframe.style.MozTransform = 'scale(' + (1/ratioX) + ', ' + (1/ratioY) + ')';
iframe.style.MozTransformOrigin = 'top left';
iframe.sandbox = 'allow-scripts allow-same-origin';
iframe.onload = function(){ pageLoaded(); }
dial.capture += 1;
if(dial.capture == 1){
dial.skipUpdate = true;
browser.webRequest.onHeadersReceived.addListener(headersReceived, { urls:['*://*/*'], types:['sub_frame'] }, ['blocking', 'responseHeaders']);
browser.tabs.update(tab.id, {muted: true}).then();
}
iframe.src = selectedItem.Node.url;
selectedItem.children[0].appendChild(iframe);
//setTimeout(function(){ pageLoaded(); }, 6000);
});
}
dial.capturePage = function(selectedItem){
selectedItem.className = 'BookmarkLoading';
selectedItem.childNodes[0].style.backgroundImage = app.settings.grid.loadingIcon;

View File

@@ -2,7 +2,7 @@
"manifest_version": 2,
"name": "Quick Dial",
"version": "0.1.5",
"version": "0.1.6",
"author": "MatMoul",
"homepage_url": "https://github.com/MatMoul/quickdial-webext",
"developer": {
@@ -21,6 +21,8 @@
"bookmarks",
"contextMenus",
"tabs",
"webRequest",
"webRequestBlocking",
"<all_urls>"
],