🚀 first release
This commit is contained in:
commit
b313bc85f3
|
|
@ -0,0 +1,2 @@
|
|||
.idea/
|
||||
*.mov
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
|
||||
Chrome MeTube Downloader
|
||||
=======
|
||||
|
||||
![example]()
|
||||
|
||||
Use the context menu to send youtube video into [MeTube](https://github.com/alexta69/metube)
|
||||
|
||||
Installation from store
|
||||
-----
|
||||
|
||||
- ~~Google Chrome~~ not available at now. Possible later
|
||||
|
||||
Installation from sources
|
||||
-----
|
||||
- Download this repository
|
||||
- Open "[Extensions](chrome://extensions/)" tab
|
||||
- Turn On "developer mode" in top right corner
|
||||
- Click "Load unpacked extension"
|
||||
- Choose folder with sources of repository
|
||||
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 3.4 MiB |
|
|
@ -0,0 +1,46 @@
|
|||
'use strict';
|
||||
|
||||
chrome.runtime.onInstalled.addListener(function () {
|
||||
// https://stackoverflow.com/questions/19377262/regex-for-youtube-url
|
||||
chrome.contextMenus.create({
|
||||
id: 'metube',
|
||||
title: "Send to MeTube",
|
||||
documentUrlPatterns: [
|
||||
'https://www.youtube.com/*',
|
||||
'https://m.youtube.com/*',
|
||||
'https://youtu.be/*'
|
||||
],
|
||||
contexts: ['link'],
|
||||
});
|
||||
});
|
||||
|
||||
chrome.contextMenus.onClicked.addListener(function (item, tab) {
|
||||
chrome.storage.sync.get(['metube'], function (data) {
|
||||
if(data === undefined || !data.hasOwnProperty('metube') ){
|
||||
// todo notify user about settings
|
||||
return
|
||||
}
|
||||
|
||||
let url = data.metube;
|
||||
let xhr = new XMLHttpRequest();
|
||||
xhr.open("POST", url + "/add", true);
|
||||
xhr.setRequestHeader("Content-Type", "application/json");
|
||||
xhr.onreadystatechange = function () {
|
||||
if (xhr.readyState === 4 && xhr.status === 200) {
|
||||
let json = JSON.parse(xhr.responseText);
|
||||
if (json.status === "ok") {
|
||||
chrome.tabs.query({url: url + "/*"}, function (tabs) {
|
||||
if (tabs.length !== 0) {
|
||||
chrome.tabs.update(tabs[0].id, {'active': true}, () => {});
|
||||
} else {
|
||||
chrome.tabs.create({url: url, index: tab.index + 1});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
alert("error :: " + json);
|
||||
}
|
||||
}
|
||||
};
|
||||
xhr.send(JSON.stringify({"quality": "best", "url": item.linkUrl}));
|
||||
});
|
||||
});
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 2.9 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 783 B |
Binary file not shown.
|
After Width: | Height: | Size: 1.6 KiB |
|
|
@ -0,0 +1,25 @@
|
|||
{
|
||||
"name": "MeTube Downloader",
|
||||
"description": "Use the context menu to send video into MeTube application",
|
||||
"version": "1.0",
|
||||
"manifest_version": 2,
|
||||
"permissions": ["contextMenus", "storage", "tabs"],
|
||||
"background": {
|
||||
"scripts": [
|
||||
"background.js"
|
||||
],
|
||||
"persistent": false
|
||||
},
|
||||
"options_ui": {
|
||||
"page": "options.html",
|
||||
"browser_style": true
|
||||
},
|
||||
"browser_action": {
|
||||
"default_popup": "options.html"
|
||||
},
|
||||
"icons": {
|
||||
"16": "icon16.png",
|
||||
"48": "icon48.png",
|
||||
"128": "icon128.png"
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="English">
|
||||
<head>
|
||||
<title>MeTube Downloader</title>
|
||||
<style>
|
||||
body {
|
||||
padding: 0 20px 20px 20px;
|
||||
min-width: 400px;
|
||||
font-size: 15px;
|
||||
}
|
||||
input {
|
||||
margin: 5px;
|
||||
outline: none;
|
||||
}
|
||||
.hidden {
|
||||
display: none;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h3>About</h3>
|
||||
<p>This extension is context menu button for sending links of youtube videos into you own instance of MeTube</p>
|
||||
<p>This extension won't work without installed MeTube. For additional instructions see <a href="https://github.com/alexta69/metube" target="_blank">github page of MeTube</a>.</p>
|
||||
<p>If you have some throubles with extension you can open issue on github page of extension.</p>
|
||||
<p> </p>
|
||||
<h3>Settings</h3>
|
||||
<form id="form">
|
||||
<label for="metube">Url of MeTube</label><input type="url" placeholder="http://0.0.0.0:8081/" name="metube" id="metube">
|
||||
<button type='submit'>Save</button>
|
||||
<p id="saved" class="hidden">Settings saved!</p>
|
||||
</form>
|
||||
</body>
|
||||
<script src="options.js"></script>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
async function saveOptions() {
|
||||
let url = document.getElementById("metube").value;
|
||||
|
||||
if (url.endsWith('/')) {
|
||||
url = url.slice(0, -1)
|
||||
}
|
||||
|
||||
chrome.storage.sync.set({"metube": url}, function () {
|
||||
document.getElementById("saved").classList.remove('hidden');
|
||||
|
||||
setTimeout(function () {
|
||||
document.getElementById("saved").classList.add('hidden');
|
||||
}, 1000 * 10)
|
||||
});
|
||||
}
|
||||
|
||||
async function restoreOptions() {
|
||||
chrome.storage.sync.get(['metube'], function (data) {
|
||||
document.getElementById("metube").value = data.metube;
|
||||
});
|
||||
}
|
||||
|
||||
window.addEventListener("DOMContentLoaded", restoreOptions, {passive: true});
|
||||
|
||||
document.querySelector("form").addEventListener("submit", (e) => {
|
||||
e.preventDefault();
|
||||
saveOptions();
|
||||
}, {passive: false});
|
||||
Loading…
Reference in New Issue