Skip to content

Commit

Permalink
No public description
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 588557237
  • Loading branch information
colaboratory-team committed Dec 6, 2023
1 parent e4ca5ca commit fd21747
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": "2.0.1",
"version_name": "2.0.1",
"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 fd21747

Please sign in to comment.