Skip to content

Commit

Permalink
Adding basic manifest, and some simple html/js to detect youtube and …
Browse files Browse the repository at this point in the history
…get the video ID.
  • Loading branch information
kyledemeule committed Dec 2, 2019
1 parent a4de5ca commit d17ab5a
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 0 deletions.
18 changes: 18 additions & 0 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"manifest_version": 2,

"name": "Innertube",
"description": "Seach Youtube videos",
"version": "1.0",

"content_security_policy": "script-src 'self' https://ajax.googleapis.com; object-src 'self'",

"browser_action": {
"default_icon": "static/base.png",
"default_popup": "views/popup.html"
},
"permissions": [
"activeTab",
"tabs"
]
}
14 changes: 14 additions & 0 deletions scripts/popup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
chrome.tabs.query({'active': true, 'lastFocusedWindow': true}, function (tabs) {
var url = tabs[0].url;
u = new URL(url);
if (u.hostname == "www.youtube.com" || u.hostname == "youtube.com") {
$('#not-youtube-warning').hide();
$('#search-content').show();
} else {
$('#not-youtube-warning').show();
$('#search-content').hide();
}
usp = new URLSearchParams(u.search);
video_id = usp.get('v');
console.log(video_id);
});
Binary file added static/base.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions views/popup.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!doctype html>
<html>
<head>
<title>Innertube - Youtube video search</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="../scripts/popup.js"></script>
</head>
<body>
<div id="search-content">
<h1>Innertube: Youtube video search.</h1>
<form>
<input type="text" name="searchtext" id="searchtext" />
<input type="submit" value="Search">
</form>
</div>
<div id="not-youtube-warning">
<p>This extension only works on www.youtube.com.</p>
</div>
</body>
</html>

0 comments on commit d17ab5a

Please sign in to comment.