diff --git a/js/background.js b/js/background.js deleted file mode 100644 index 693a731..0000000 --- a/js/background.js +++ /dev/null @@ -1,46 +0,0 @@ -/* - Copyright 2018 Google LLC - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -// This listener is called when the user clicks the extension icon. - -// If the current URL matches a Jupyter notebook hosted on github.com -// or on gist.github.com, this function will open a new tab and load -// the notebook into Colab. - -chrome.action.onClicked.addListener(function(tab) { - const colab_url = 'https://colab.research.google.com/'; - const github = /^https?:\/\/github\.com\/(.+)\/(.*\.ipynb)$/; - const gist = - /^https?:\/\/gist\.github\.com\/(.+)\/([a-f0-9]+(?:\#file\-.*\-ipynb)?)$/; - - let path = null; - let url = null; - - if (github.test(tab.url)) { - path = github.exec(tab.url); - url = colab_url + ['github', path[1], path[2]].join('/'); - } else if (gist.test(tab.url)) { - path = gist.exec(tab.url); - url = colab_url + ['gist', path[1], path[2]].join('/'); - } - - if (url) { - chrome.tabs.create({'url': url}); - } else { - console.warn(`Current page (${ - tab.url}) is not recognized as a GitHub-hosted notebook.`); - } -}); diff --git a/manifest.json b/manifest.json index 3b772a2..cec3a5d 100644 --- a/manifest.json +++ b/manifest.json @@ -18,7 +18,7 @@ "default_title": "Open notebook in Google Colab" }, "background": { - "service_worker": "js/background.js" + "service_worker": "service_worker_compiled.js" }, "permissions": ["activeTab"] }