v1.2.0-beta/fix file structure
|
After Width: | Height: | Size: 2.0 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
@@ -0,0 +1,131 @@
|
||||
/* global chrome */
|
||||
/*global firebase*/
|
||||
|
||||
const firebaseConfig = {
|
||||
apiKey: 'AIzaSyCJLuYpzXLDRmu2ttzFuSGmYcpFxqToWFU',
|
||||
authDomain: 'watch-party-crx.firebaseapp.com',
|
||||
databaseURL: 'https://watch-party-crx.firebaseio.com',
|
||||
projectId: 'watch-party-crx',
|
||||
storageBucket: 'watch-party-crx.appspot.com',
|
||||
messagingSenderId: '712242707190',
|
||||
appId: '1:712242707190:web:65fa7f772e30da364b0ad7',
|
||||
measurementId: 'G-EZS4PEVG4T',
|
||||
};
|
||||
|
||||
firebase.initializeApp(firebaseConfig);
|
||||
firebase.auth().setPersistence(firebase.auth.Auth.Persistence.LOCAL);
|
||||
|
||||
const isAuthed = () => true && firebase.auth().currentUser;
|
||||
const doAuth = () => firebase.auth().signInAnonymously();
|
||||
|
||||
const fetcher = async (request, sendResponse) => {
|
||||
if (!isAuthed()) await doAuth();
|
||||
const { url, method } = request;
|
||||
delete request.type;
|
||||
delete request.url;
|
||||
delete request.method;
|
||||
const idToken = await firebase.auth().currentUser.getIdToken();
|
||||
let resStatus = {};
|
||||
fetch(url, {
|
||||
method,
|
||||
headers: {
|
||||
Authorization: `Token ${idToken}:${firebase.auth().currentUser.uid}`,
|
||||
'Access-Control-Allow-Origin': '*',
|
||||
},
|
||||
...request,
|
||||
})
|
||||
.then((res) => {
|
||||
resStatus = {
|
||||
status: res.status,
|
||||
statusText: res.statusText,
|
||||
};
|
||||
return res.json();
|
||||
})
|
||||
.then((res) => sendResponse({ ...res, ...resStatus }))
|
||||
.catch((err) => sendResponse({ ...err, status: 503, statusText: "Couldn't talk to server" }));
|
||||
};
|
||||
|
||||
const sendAuth = async (sendResponse) => {
|
||||
if (!isAuthed()) await doAuth();
|
||||
sendResponse(firebase.auth().currentUser);
|
||||
};
|
||||
|
||||
chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
|
||||
const { type } = request;
|
||||
switch (type) {
|
||||
case 'API_CALL':
|
||||
fetcher(request, sendResponse);
|
||||
break;
|
||||
case 'GET_AUTH':
|
||||
sendAuth(sendResponse);
|
||||
break;
|
||||
default:
|
||||
console.warn('Unknown message type: <', type, '>');
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
chrome.runtime.onConnect.addListener((port) => {
|
||||
port.onDisconnect.addListener(() => {
|
||||
port.roomListener && port.roomListener();
|
||||
port.userListener && port.userListener();
|
||||
port.messageListener && port.messageListener();
|
||||
});
|
||||
port.onMessage.addListener((request) => {
|
||||
const { type, roomId } = request;
|
||||
if (type === 'INIT') {
|
||||
port.roomListener = firebase
|
||||
.firestore()
|
||||
.collection('rooms')
|
||||
.doc(roomId)
|
||||
.onSnapshot(
|
||||
(snap) => {
|
||||
if (snap) {
|
||||
port.postMessage(snap.data());
|
||||
}
|
||||
},
|
||||
(err) => {
|
||||
port.postMessage({ isError: true, ...err });
|
||||
}
|
||||
);
|
||||
port.userListener = firebase
|
||||
.firestore()
|
||||
.collection('rooms')
|
||||
.doc(roomId)
|
||||
.collection('users')
|
||||
.onSnapshot(
|
||||
(snap) => {
|
||||
if (snap) {
|
||||
const isAdmin = snap.docs
|
||||
.filter((user) => user.id === firebase.auth().currentUser.uid)[0]
|
||||
.data().admin;
|
||||
port.postMessage({ admin: isAdmin });
|
||||
}
|
||||
},
|
||||
(err) => {
|
||||
port.postMessage({ isError: true, ...err });
|
||||
}
|
||||
);
|
||||
port.messageListener = firebase
|
||||
.firestore()
|
||||
.collection('rooms')
|
||||
.doc(roomId)
|
||||
.collection('messages')
|
||||
.orderBy('time')
|
||||
.onSnapshot(
|
||||
(snap) => {
|
||||
if (snap) {
|
||||
let messages = snap.docs.map((v) => ({ ...v.data(), id: v.id }));
|
||||
port.postMessage({
|
||||
messages,
|
||||
});
|
||||
}
|
||||
},
|
||||
(err) => {
|
||||
port.postMessage({ isError: true, ...err });
|
||||
}
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
After Width: | Height: | Size: 5.0 KiB |
|
After Width: | Height: | Size: 915 B |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 1.7 KiB |
|
After Width: | Height: | Size: 1.1 KiB |
@@ -0,0 +1,7 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body>
|
||||
<noscript>You need to enable JavaScript to run this app.</noscript>
|
||||
<div id="root"></div>
|
||||
</body>
|
||||
</html>
|
||||
|
After Width: | Height: | Size: 8.1 KiB |
|
After Width: | Height: | Size: 11 KiB |
@@ -0,0 +1,66 @@
|
||||
{
|
||||
"name": "Watch Party",
|
||||
"short_name": "WP",
|
||||
"version": "1.2.0",
|
||||
"description": "Watch streamed content together.",
|
||||
"background": {
|
||||
"page": "popup.html"
|
||||
},
|
||||
"permissions": [
|
||||
"https://*.hulu.com/*",
|
||||
"https://*.netflix.com/*",
|
||||
"https://*.amazon.com/*",
|
||||
"https://*.disneyplus.com/*",
|
||||
"https://*.youtube.com/*",
|
||||
"https://play.hbonow.com/*"
|
||||
],
|
||||
"content_security_policy": "script-src 'self' https://www.gstatic.com/ https://*.firebaseio.com https://www.googleapis.com; object-src 'self'",
|
||||
"content_scripts": [
|
||||
{
|
||||
"matches": ["https://*.hulu.com/*"],
|
||||
"run_at": "document_idle",
|
||||
"js": ["/static/js/content.js"],
|
||||
"css": ["/static/css/app.css"]
|
||||
},
|
||||
{
|
||||
"matches": ["https://*.netflix.com/*"],
|
||||
"run_at": "document_idle",
|
||||
"js": ["/static/js/content.js"],
|
||||
"css": ["/static/css/app.css"]
|
||||
},
|
||||
{
|
||||
"matches": ["https://*.amazon.com/*"],
|
||||
"run_at": "document_idle",
|
||||
"js": ["/static/js/content.js"],
|
||||
"css": ["/static/css/app.css"]
|
||||
},
|
||||
{
|
||||
"matches": ["https://*.disneyplus.com/*"],
|
||||
"run_at": "document_idle",
|
||||
"js": ["/static/js/content.js"],
|
||||
"css": ["/static/css/app.css"]
|
||||
},
|
||||
{
|
||||
"matches": ["https://*.youtube.com/*"],
|
||||
"run_at": "document_idle",
|
||||
"js": ["/static/js/content.js"],
|
||||
"css": ["/static/css/app.css"]
|
||||
},
|
||||
{
|
||||
"matches": ["https://play.hbonow.com/*"],
|
||||
"run_at": "document_idle",
|
||||
"js": ["/static/js/content.js"],
|
||||
"css": ["/static/css/app.css"]
|
||||
}
|
||||
],
|
||||
"web_accessible_resources": ["android-icon-192x192.png"],
|
||||
"icons": {
|
||||
"16": "favicon-16x16.png",
|
||||
"32": "favicon-32x32.png",
|
||||
"96": "favicon-96x96.png",
|
||||
"128": "favicon-128x128.png",
|
||||
"144": "android-icon-144x144.png",
|
||||
"192": "android-icon-192x192.png"
|
||||
},
|
||||
"manifest_version": 2
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta
|
||||
http-equiv="Content-Security-Policy"
|
||||
content="default-src *; style-src 'self' https://* 'unsafe-inline'; script-src 'self' http://* 'unsafe-inline' 'unsafe-eval'"
|
||||
/>
|
||||
<style>
|
||||
html {
|
||||
height: fit-content;
|
||||
width: fit-content;
|
||||
}
|
||||
body {
|
||||
margin: 0;
|
||||
min-width: 200px;
|
||||
background-color: rgba(46, 46, 46, 1);
|
||||
height: fit-content;
|
||||
}
|
||||
a:hover {
|
||||
filter: drop-shadow(0 0 10px black);
|
||||
}
|
||||
a {
|
||||
border-radius: 13px;
|
||||
font-family: sans-serif;
|
||||
font-weight: 500;
|
||||
display: block;
|
||||
user-select: none;
|
||||
color: black;
|
||||
text-decoration: none;
|
||||
padding: 5px 10px;
|
||||
text-align: center;
|
||||
margin: 10px 10px;
|
||||
}
|
||||
a:nth-child(1) {
|
||||
background-color: rgb(23, 245, 160);
|
||||
}
|
||||
a:nth-child(2) {
|
||||
background-color: rgb(235, 77, 77);
|
||||
}
|
||||
a:nth-child(3) {
|
||||
background-color: cornflowerblue;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<script src="https://www.gstatic.com/firebasejs/7.14.1/firebase-app.js"></script>
|
||||
<script src="https://www.gstatic.com/firebasejs/7.14.1/firebase-auth.js"></script>
|
||||
<script src="https://www.gstatic.com/firebasejs/7.14.1/firebase-firestore.js"></script>
|
||||
<script src="background.js"></script>
|
||||
<a target="_blank" href="https://www.hulu.com/">Hulu</a>
|
||||
<a target="_blank" href="https://www.netflix.com/browse">Netflix</a>
|
||||
<a target="_blank" href="https://www.amazon.com/gp/video/storefront">Prime Video</a>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,3 @@
|
||||
# https://www.robotstxt.org/robotstxt.html
|
||||
User-agent: *
|
||||
Disallow:
|
||||