Skip to content

Commit

Permalink
No public description
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 702520489
  • Loading branch information
colaboratory-team committed Dec 14, 2024
1 parent cfe2b56 commit f4d893d
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
21 changes: 21 additions & 0 deletions help.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!DOCTYPE html>
<meta charset="utf-8">
<html lang="en">
<head>
<title>Open in Colab</title>
<style>
body {
width: 20rem;
}
</style>
</head>
<body>
<p>
This page is not supported.
</p>
<p>
<a target="_blank" href="https://chromewebstore.google.com/detail/open-in-colab/iogfkhleblhcpcekbiedikdehleodpjo">Open in Colab</a>
supports GitHub-hosted .ipynb files.
</p>
</body>
</html>
14 changes: 14 additions & 0 deletions service_worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@

import {githubToColabUrl} from './parse';

// Details for calls to chrome.action.setPopup; see
// https://developer.chrome.com/docs/extensions/reference/api/action#method-setPopup.
const EMPTY_POPUP = {
popup: ''
};
const HELP_POPUP = {
popup: 'help.html'
};

// 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
Expand All @@ -29,6 +38,11 @@ chrome.action.onClicked.addListener((tab: chrome.tabs.Tab) => {
}
const colabUrl = githubToColabUrl(tab.url);
if (!colabUrl) {
chrome.action.setPopup(HELP_POPUP, () => {
chrome.action.openPopup({}, () => {
chrome.action.setPopup(EMPTY_POPUP);
});
});
console.warn(`Current page (${
tab.url}) is not recognized as a GitHub-hosted notebook.`);
return;
Expand Down

0 comments on commit f4d893d

Please sign in to comment.