diff --git a/manifest.json b/manifest.json index 8179351f..b60ea20c 100644 --- a/manifest.json +++ b/manifest.json @@ -2,7 +2,7 @@ "name": "Social Stream Ninja", "description": "Powerful tooling to engage live chat on Youtube, Twitch, Zoom, and more.", "manifest_version": 3, - "version": "3.12.11", + "version": "3.12.12", "homepage_url": "http://socialstream.ninja/", "icons": { "128": "icons/icon-128.png" diff --git a/sources/youtube.js b/sources/youtube.js index 00e2abc3..ca79276b 100644 --- a/sources/youtube.js +++ b/sources/youtube.js @@ -395,22 +395,22 @@ } async function processMessage(ele, wss = true, eventType=false) { - console.log(ele); + //console.log(ele); if (!ele || !ele.isConnected){ - return; + return 1; } if (ele.hasAttribute("is-deleted")) { deleteThis(ele) - return; + return 2; } if (settings.customyoutubestate) { - return; + return 3; } try { if (ele.skip) { - return; + return 4; } else if (ele.id) { - if (messageHistory.has(ele.id)) return; + if (messageHistory.has(ele.id)) return 5; messageHistory.add(ele.id); if (messageHistory.size > 300) { // 250 seems to be Youtube's max? const iterator = messageHistory.values(); @@ -435,26 +435,16 @@ } //console.log(messageHistory); } else { - return; // no id. + return 6; // no id. } if (ele.querySelector("[in-banner]")) { //console.log("Message in-banner"); - return; + return 7; } } catch (e) {} ele.skip = true; - //if (channelName && settings.customyoutubestate){ - //if (settings.customyoutubeaccount && settings.customyoutubeaccount.textsetting && (settings.customyoutubeaccount.textsetting.toLowerCase() !== channelName.toLowerCase())){ - // return; - //} else if (!settings.customyoutubeaccount){ - // return; - //} - // } - - - //
12:38 AMStephanie Warfield
New member
ewww 🤮🤢
var chatmessage = ""; var chatname = ""; @@ -466,12 +456,12 @@ var donoValue = ""; var srcImg = ""; // what shows up as the source image; blank is default (dock decides). - + try { var nameElement = ele.querySelector("#author-name"); chatname = escapeHtml(nameElement.innerText); if (!chatname){ - return; + return 8; } ele.querySelectorAll('yt-live-chat-author-badge-renderer[type]').forEach(type=>{ @@ -665,7 +655,7 @@ if (settings.memberchatonly && !hasMembership){ - return; + return 9; } if (giftedmemembership && !hasDonation) { @@ -718,8 +708,17 @@ } if (!chatmessage && !hasDonation) { - //console.error("No message or donation"); - return; + let donat = ele.querySelector("#text.yt-live-chat-donation-announcement-renderer"); + if (donat){ + chatmessage = getAllContentNodes(donat).trim(); + eventType = "donation"; + if (chatmessage.split(" donated ").length>=2){ + hasDonation = chatmessage.split(" donated ").pop().trim(); + } + } + if (!chatmessage){ + return 10; + } } chatmessage = chatmessage.trim(); @@ -736,9 +735,6 @@ chatmessage = ""; } - - - var data = {}; data.chatname = chatname; data.nameColor = nameColor; @@ -766,6 +762,8 @@ data.type = "youtubeshorts"; } + // console.log(data); + if (data.hasDonation){ data.title = getTranslation("donation", "DONATION"); if (!data.chatmessage){ @@ -779,7 +777,7 @@ data.event = eventType; //if (eventType){ - // console.log(data); + //console.log(data); //} try { @@ -944,10 +942,10 @@ }); function onElementInserted(target, callback) { - console.log(target); + //console.log(target); var onMutationsObserved = function (mutations) { mutations.forEach(function (mutation) { - console.log(mutation.addedNodes); + //console.log(mutation.addedNodes); if (mutation.addedNodes.length) { for (var i = 0, len = mutation.addedNodes.length; i < len; i++) { try { @@ -959,6 +957,9 @@ callback(mutation.addedNodes[i]); } else if (mutation.addedNodes[i].tagName == "yt-live-chat-membership-item-renderer".toUpperCase()) { callback(mutation.addedNodes[i]); + } else if (mutation.addedNodes[i].tagName == "yt-live-chat-donation-announcement-renderer".toUpperCase()) { + //console.log(mutation.addedNodes[i]); + callback(mutation.addedNodes[i]) } else if (mutation.addedNodes[i].tagName == "yt-live-chat-paid-sticker-renderer".toUpperCase()) { callback(mutation.addedNodes[i]); } else if (mutation.addedNodes[i].tagName == "ytd-sponsorships-live-chat-gift-redemption-announcement-renderer".toUpperCase()) { @@ -966,6 +967,8 @@ } else if (mutation.addedNodes[i].tagName == "ytd-sponsorships-live-chat-gift-purchase-announcement-renderer".toUpperCase()) { // ytd-sponsorships-live-chat-gift-purchase-announcement-renderer callback(mutation.addedNodes[i], "giftpurchase"); + } else if (mutation.addedNodes[i].tagName.startsWith("ytd-sponsorship") || mutation.addedNodes[i].tagName.startsWith("yt-live-chat")){ + callback(mutation.addedNodes[i]); } else { //console.error("unknown: "+mutation.addedNodes[i].tagName); } @@ -1027,9 +1030,9 @@ // Add event listener to the button button.addEventListener('click', () => { - const videoId = input.value.trim(); - if (videoId) { - window.location.href = `https://www.youtube.com/live_chat?is_popout=1&v=${videoId}`; + const videoId123 = input.value.trim(); + if (videoId123) { + window.location.href = `https://www.youtube.com/live_chat?is_popout=1&v=${videoId123}`; } else { alert('Please enter a valid video ID'); }