Skip to content

Commit

Permalink
Keyboard shotcut
Browse files Browse the repository at this point in the history
  • Loading branch information
SleekPanther committed Jul 10, 2018
1 parent cb42f11 commit a75651d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
# youtube-chronological-order
YouTube Chronological Order Chrome Extension
20 changes: 15 additions & 5 deletions background.js
Original file line number Diff line number Diff line change
@@ -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()
}
})
6 changes: 3 additions & 3 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit a75651d

Please sign in to comment.