creating messanger for content scripst
to pass messages to overlay
This commit is contained in:
12
src/chat_overlay.js
Normal file
12
src/chat_overlay.js
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
const message_container = document.getElementById("message_container");
|
||||||
|
|
||||||
|
|
||||||
|
chrome.runtime.onMessage.addListener(
|
||||||
|
function(request, sender, sendResponse) {
|
||||||
|
|
||||||
|
if (request.message == "messageNode"){
|
||||||
|
message_container.innerHTML += request.node;
|
||||||
|
message_container.scrollBy(message_container.scrollHeight);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
});
|
||||||
@@ -2,8 +2,6 @@ import Emotes from './Emotes';
|
|||||||
import Message from './Message';
|
import Message from './Message';
|
||||||
import PersistentSyncStorage from 'src/helpers/PersistentSyncStorage';
|
import PersistentSyncStorage from 'src/helpers/PersistentSyncStorage';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class ChatWatcher {
|
class ChatWatcher {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
@@ -14,7 +12,6 @@ class ChatWatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
|
|
||||||
return new Promise((res, rej) => {
|
return new Promise((res, rej) => {
|
||||||
this.getChatContainer().then(Emotes.init).then(() => {
|
this.getChatContainer().then(Emotes.init).then(() => {
|
||||||
this.addEmotePopup();
|
this.addEmotePopup();
|
||||||
@@ -54,8 +51,6 @@ class ChatWatcher {
|
|||||||
|
|
||||||
mutations.forEach(mutation => {
|
mutations.forEach(mutation => {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const { addedNodes, removedNodes } = mutation;
|
const { addedNodes, removedNodes } = mutation;
|
||||||
|
|
||||||
// Added nodes
|
// Added nodes
|
||||||
@@ -186,8 +181,6 @@ class ChatWatcher {
|
|||||||
emoteAppend(keysITer);
|
emoteAppend(keysITer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// add div to doc
|
// add div to doc
|
||||||
chatButtonSelectionList.appendChild(popUpDiv);
|
chatButtonSelectionList.appendChild(popUpDiv);
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
import Emotes from './Emotes';
|
import Emotes from './Emotes';
|
||||||
import PersistentSyncStorage from 'src/helpers/PersistentSyncStorage';
|
import PersistentSyncStorage from 'src/helpers/PersistentSyncStorage';
|
||||||
|
|
||||||
|
let chat_overlay_enabled = false;
|
||||||
|
|
||||||
|
|
||||||
class Message {
|
class Message {
|
||||||
constructor(messageNode) {
|
constructor(messageNode) {
|
||||||
this.node = messageNode;
|
this.node = messageNode;
|
||||||
@@ -17,6 +20,10 @@ class Message {
|
|||||||
this.setHtml();
|
this.setHtml();
|
||||||
this.watch();
|
this.watch();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
chrome.runtime.sendMessage({message: "messageNode", node: messageNode.outerHTML}, function(response) {
|
||||||
|
// dont need to do anything
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
get textNode() {
|
get textNode() {
|
||||||
@@ -202,15 +209,7 @@ class Message {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
// removes color attr
|
|
||||||
removelternateLineColor(){
|
|
||||||
this.node.classList.remove("set-background-color-one");
|
|
||||||
this.node.classList.remove("set-background-color-two");
|
|
||||||
}
|
|
||||||
|
|
||||||
}// end Message
|
}// end Message
|
||||||
|
|
||||||
export default Message;
|
export default Message;
|
||||||
19
src/html/chat_overlay.html
Normal file
19
src/html/chat_overlay.html
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||||
|
<title>Chat Overlay</title>
|
||||||
|
<link rel="stylesheet" href="./youtube_styling.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<style>
|
||||||
|
yt-live-chat-text-message-renderer{
|
||||||
|
background-color: transparent !important;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<div id="message_container"></div>
|
||||||
|
<script src="../chat_overlay.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -136,6 +136,10 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
<button class="chat_overlay" id="chat_overlay" >Chat Overlay</button>
|
||||||
|
|
||||||
<div id="save-status"> </div>
|
<div id="save-status"> </div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
14465
src/html/youtube_styling.css
Normal file
14465
src/html/youtube_styling.css
Normal file
File diff suppressed because it is too large
Load Diff
@@ -180,4 +180,9 @@ PersistentSyncStorage.on('ready', () => {
|
|||||||
var infoButton = document.getElementById('infoButton');
|
var infoButton = document.getElementById('infoButton');
|
||||||
infoButton.addEventListener('click', function(){
|
infoButton.addEventListener('click', function(){
|
||||||
chrome.tabs.create({ url: 'https://wompmacho.com/wompchat' });
|
chrome.tabs.create({ url: 'https://wompmacho.com/wompchat' });
|
||||||
|
});
|
||||||
|
|
||||||
|
var chat_overlay = document.getElementById('chat_overlay');
|
||||||
|
chat_overlay.addEventListener('click', function(){
|
||||||
|
chrome.tabs.create({ url: 'html/chat_overlay.html' });
|
||||||
});
|
});
|
||||||
@@ -23,7 +23,8 @@ module.exports = {
|
|||||||
content: './content/',
|
content: './content/',
|
||||||
background: './background/',
|
background: './background/',
|
||||||
options: './options.js',
|
options: './options.js',
|
||||||
welcomePage: './welcomePage.js'
|
welcomePage: './welcomePage.js',
|
||||||
|
chat_overlay: './chat_overlay.js'
|
||||||
|
|
||||||
},
|
},
|
||||||
output: {
|
output: {
|
||||||
|
|||||||
@@ -24,7 +24,8 @@ module.exports = {
|
|||||||
content: './content/',
|
content: './content/',
|
||||||
background: './background/',
|
background: './background/',
|
||||||
options: './options.js',
|
options: './options.js',
|
||||||
welcomePage: './welcomePage.js'
|
welcomePage: './welcomePage.js',
|
||||||
|
chat_overlay: './chat_overlay.js'
|
||||||
},
|
},
|
||||||
output: {
|
output: {
|
||||||
path: distPath,
|
path: distPath,
|
||||||
|
|||||||
Reference in New Issue
Block a user