Skip to content

Commit

Permalink
No public description
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 588854901
  • Loading branch information
colaboratory-team committed Dec 7, 2023
1 parent e4ca5ca commit d6dc0c8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
7 changes: 4 additions & 3 deletions js/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,20 @@
// or on gist.github.com, this function will open a new tab and load
// the notebook into Colab.

chrome.browserAction.onClicked.addListener(function(tab) {
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, url = null;
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(page.url);
path = gist.exec(tab.url);
url = colab_url + ['gist', path[1], path[2]].join('/');
}

Expand Down
17 changes: 10 additions & 7 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
{
"name": "Open in Colab",
"description": "Open a Github-hosted notebook in Google Colab",
"version": "1.0.1",
"version_name": "1.0.1",
"manifest_version": 2,
"version": "1.1.0",
"version_name": "1.1.0",
"manifest_version": 3,
"icons": {
"16": "images/icon16.png",
"32": "images/icon32.png",
"128": "images/icon128.png"
},
"browser_action": {
"default_icon": "images/icon16.png",
"action": {
"default_icon": {
"16": "images/icon16.png",
"32": "images/icon32.png",
"128": "images/icon128.png"
},
"default_title": "Open notebook in Google Colab"
},
"background": {
"scripts": ["js/background.js"],
"persistent": false
"service_worker": "js/background.js"
},
"permissions": ["activeTab"]
}

0 comments on commit d6dc0c8

Please sign in to comment.