diff --git a/addon/content.coffee b/addon/content.coffee new file mode 100644 index 00000000..2d0d796b --- /dev/null +++ b/addon/content.coffee @@ -0,0 +1,10 @@ +# Just a test +# +# + +console.log("hello") + +historyHandler = (message) -> + window.history.go(message.number) + +browser.runtime.onMessage.addListener(historyHandler) diff --git a/addon/main.coffee b/addon/main.coffee index 68890e56..ba13c097 100644 --- a/addon/main.coffee +++ b/addon/main.coffee @@ -77,9 +77,20 @@ tabByIndex = (index) -> desiredTab = tab for tab in tabs when tab.index == desIndex ) +goHistory = (n) -> + browser.tabs.query({active:true}).then( + (tabs) -> + activeTab = tabs[0] + browser.tabs.executeScript(activeTab.id, {file:"content.js"}) + # We could use null in executeScript, and it would default to active tab + # but I think that is less readable + browser.tabs.sendMessage(activeTab.id,{number:n}) + ) + + + Number.prototype.mod = (n) -> ((this%n)+n)%n # Javascript doens't understand maths - # Lots of people use myFunc: ()-> \\ rather than \\ myFunc = () -> \\ do we care? console.log("Loaded Tridactyl") diff --git a/addon/manifest.json b/addon/manifest.json index 8f9a10cf..a9c2aa76 100644 --- a/addon/manifest.json +++ b/addon/manifest.json @@ -11,6 +11,30 @@ "browser_action": { "default_title": "Tridactyl", "browser_style": true - } + }, + + "permissions": [ + "activeTab", + "alarms", + "bookmarks", + "contextMenus", + "cookies", + "downloads", + "downloads.open", + "history", + "identity", + "idle", + "management", + "nativeMessaging", + "notifications", + "sessions", + "storage", + "tabs", + "topSites", + "webNavigation", + "webRequest", + "webRequestBlocking", + "" + ] } diff --git a/ideas.md b/ideas.md index 119538ed..ca953e1c 100644 --- a/ideas.md +++ b/ideas.md @@ -65,5 +65,10 @@ Loading into firefox doesn't give any errors / doesn't seem to expose any functi # Other stuff Would be nice to have self-writing documentation, for autocmd use etc? +Could use .litcoffee for markdown comments in code. History seems to be window.history.go(), presumably in a content script? + +https://news.ycombinator.com/item?id=10120773 -- people complaining, could be handy + +https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/tabs/executeScript -- we aren't allowed to inject JS into, e.g. about: pages. This means no searching, no back/forward, no commandline: a user navigating to such a page would get trapped.