From e5783688f73af7dc1810c73d82d5381c40c59e94 Mon Sep 17 00:00:00 2001 From: Cibin Mathew <10793628+cibinmathew@users.noreply.github.com> Date: Sun, 24 Sep 2023 22:13:18 +0200 Subject: [PATCH 1/2] Manage window --- src/background/start.js | 66 +++++++++++++++++++++++++++++++ src/content_scripts/ui/omnibar.js | 5 ++- src/manifest.json | 2 +- 3 files changed, 70 insertions(+), 3 deletions(-) diff --git a/src/background/start.js b/src/background/start.js index 6734d9ea7..c868eca54 100644 --- a/src/background/start.js +++ b/src/background/start.js @@ -985,6 +985,20 @@ function start(browser) { chrome.tabs.move(tab.id, {windowId, index: -1}); }); }; + + self.sortTabs = function(message, sender, sendResponse) { + const windowId = sender.tab.windowId; + var i=1; + console.log("Sorting tab") + message.tabs.forEach(function(tab) { + console.log("Sorting tab : " + i + " " + tab.url); + i=i+1 + chrome.tabs.move(tab.id, {windowId, index: -1}); + // RUNTIME('moveTab', { position: 1 }); + + }); + }; + self.getBookmarkFolders = function(message, sender, sendResponse) { chrome.bookmarks.getTree(function(tree) { bookmarkFolders = []; @@ -1622,6 +1636,58 @@ function start(browser) { chrome.tts.stop(); }; + self.manageWindow = function(message, sender, sendResponse) { + console.log("hello"); + var tabId; + // chrome.windows.getAll({ + // populate: false + // }, function(windows) { + // windows.forEach(function(w) { + // console.log(w.id); + // }); + // }); + + var wid; + // chrome.storage.local.set({ key: value }).then(() => { + // console.log("Value is set"); + // }); + + + + if (message.bookmark) + { + // console.log("bookmarking current window: " + wid); + // return wid; + chrome.windows.getCurrent({ + populate: false + }, function(w) { + console.log("getting current window: " + w.id); + // return w.id + // chrome.tabs.getCurrent(function (tab) { + // console.log(tab.id); + // tabId = tab.id; + // _response(message, sendResponse, { + // tabs: w.id, + // tabId: tab.id + // }); + // }); + _response(message, sendResponse, { + tabs: w.id + }); + + }); + return + } + else { + console.log("opening bookmarked window: " + message.wid); + chrome.windows.update(message.wid, { + focused: true + }); + console.log("opened bookmarked window: " + message.wid); + } + }; + + self.openIncognito = function(message, sender, sendResponse) { chrome.windows.create({"url": message.url, "incognito": true}); }; diff --git a/src/content_scripts/ui/omnibar.js b/src/content_scripts/ui/omnibar.js index 7a50edca0..631f5166e 100644 --- a/src/content_scripts/ui/omnibar.js +++ b/src/content_scripts/ui/omnibar.js @@ -1488,9 +1488,10 @@ function OpenUserURLs(omnibar) { _items = args; self.onInput(); }; - + // Fixes: https://github.com/brookhong/Surfingkeys/issues/2026 + // Also supports any order of words self.onInput = function() { - var query = omnibar.input.value; + var query = omnibar.input.value.replace(/\s\s+/g, ' ').trim().toLowerCase(); var urls = []; urls = filterByTitleOrUrl(_items, query); diff --git a/src/manifest.json b/src/manifest.json index 31e91a6f9..f02cefb70 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -1,6 +1,6 @@ { "manifest_version": 2, - "name": "Surfingkeys", + "name": "Surfingkeys-Cibin", "short_name": "Rich shortcuts in vim spirit for productivity with keyboard.", "description": "Rich shortcuts to click links/switch tabs/scroll, capture pages, use your browser like vim for productivity.", "icons": { From bcc19dde93b49bd2816efaa2f542b22bcdd5ccdc Mon Sep 17 00:00:00 2001 From: Cibin Mathew Date: Sun, 10 Dec 2023 13:54:40 +0100 Subject: [PATCH 2/2] search using string --- src/content_scripts/common/normal.js | 9 +++++++++ src/content_scripts/ui/frontend.js | 28 ++++++++++++++++++++++++++-- src/content_scripts/ui/omnibar.js | 5 ++--- 3 files changed, 37 insertions(+), 5 deletions(-) diff --git a/src/content_scripts/common/normal.js b/src/content_scripts/common/normal.js index e685e854b..3e1e8f035 100644 --- a/src/content_scripts/common/normal.js +++ b/src/content_scripts/common/normal.js @@ -933,6 +933,15 @@ function createNormal(insert) { } }); + self.mappings.add("q", { + annotation: "Find in current page cibin", + feature_group: 9, + repeatIgnore: true, + code: function() { + dispatchSKEvent('openFinderCibin'); + } + }); + self.mappings.add("E", { annotation: "Go one tab left", feature_group: 3, diff --git a/src/content_scripts/ui/frontend.js b/src/content_scripts/ui/frontend.js index 3fd4fba2d..91964f5ef 100644 --- a/src/content_scripts/ui/frontend.js +++ b/src/content_scripts/ui/frontend.js @@ -461,9 +461,20 @@ const Front = (function() { setSanitizedContent(_omnibar.querySelector('style'), `#sk_omnibar {${style}}`); }; self.openOmnibar = _actions['openOmnibar']; - _actions['openFinder'] = function() { + + _actions['openFinder'] = function(arg) { + console.log("cibin.w4asdf") Find.open(); }; + + _actions['openFinderCibin'] = function(arg) { + console.log("cibin.w4") + Find.openq("the"); + }; + document.addEventListener("surfingkeys:openFinderCibin", function(evt) { + Find.openq("the"); + }); + document.addEventListener("surfingkeys:openFinder", function(evt) { Find.open(); }); @@ -775,7 +786,20 @@ var Find = (function() { * * @return {undefined} */ - self.open = function() { + self.openq=function(arg) { + var query='the' + console.log("cibin find.open: "); + reset(); + Front.visualCommand({ + action: 'visualEnter', + query: query + }); + runtime.updateHistory('find', query); + } + + self.open = function(arg) { + console.log("arg: "); + console.log(arg); historyInc = -1; StatusBar.show(1, ''); input = Front.statusBar.querySelector("input"); diff --git a/src/content_scripts/ui/omnibar.js b/src/content_scripts/ui/omnibar.js index 631f5166e..7a50edca0 100644 --- a/src/content_scripts/ui/omnibar.js +++ b/src/content_scripts/ui/omnibar.js @@ -1488,10 +1488,9 @@ function OpenUserURLs(omnibar) { _items = args; self.onInput(); }; - // Fixes: https://github.com/brookhong/Surfingkeys/issues/2026 - // Also supports any order of words + self.onInput = function() { - var query = omnibar.input.value.replace(/\s\s+/g, ' ').trim().toLowerCase(); + var query = omnibar.input.value; var urls = []; urls = filterByTitleOrUrl(_items, query);