From a75651db356041aace4aba546b3c8c8441072341 Mon Sep 17 00:00:00 2001 From: SleekPanther Date: Tue, 10 Jul 2018 16:25:53 -0400 Subject: [PATCH] Keyboard shotcut --- README.md | 2 +- background.js | 20 +++++++++++++++----- manifest.json | 6 +++--- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 820fe11..2640529 100644 --- a/README.md +++ b/README.md @@ -1 +1 @@ -# youtube-chronological-order \ No newline at end of file +YouTube Chronological Order Chrome Extension diff --git a/background.js b/background.js index ab7e601..a01aeb5 100644 --- a/background.js +++ b/background.js @@ -1,15 +1,25 @@ const MAGIC_URL_POSTFIX = '&list=ULcxqQ59vzyTk' -chrome.browserAction.onClicked.addListener((tab)=>{ - //chrome.tabs.executeScript(null, {file: "testScript.js"}) - chrome.tabs.query({'active': true, 'lastFocusedWindow': true}, (tabs)=>{ +chrome.browserAction.onClicked.addListener(tab=>{ + appendToUrl() +}) + +function appendToUrl(){ + chrome.tabs.query({'active': true, 'lastFocusedWindow': true}, tabs=>{ let currentTab = tabs[0] let oldURL = currentTab.url - console.log('url=', oldURL) + console.log('old url=', oldURL) let newUrl = oldURL + MAGIC_URL_POSTFIX chrome.tabs.update(currentTab.id, {url: newUrl}) }) -}) +} + +//Keyboard Shortcut +chrome.commands.onCommand.addListener(command => { + if(command === 'appendToUrl'){ + appendToUrl() + } +}) \ No newline at end of file diff --git a/manifest.json b/manifest.json index 65a4446..a538f1c 100644 --- a/manifest.json +++ b/manifest.json @@ -3,12 +3,12 @@ "name": "YouTube Chronological Order", "description": "Watch YouTube videos in chronological order from any channel", - "version": "0.1.0", - "version_name": "0.1.0", + "version": "0.2.0", + "version_name": "0.2.0", "browser_action": { // "default_icon": "assets/icons/icon.png", - "default_title": "Watch videos in chronological order" + "default_title": "(Alt+P) Watch channel videos in chronological order" }, "permissions": [ "activeTab",