Skip to content

Commit

Permalink
Merge pull request #347 from steveseguin/beta
Browse files Browse the repository at this point in the history
loco.gg to loco.com fix
  • Loading branch information
steveseguin authored Jan 7, 2025
2 parents 206118c + 71d578e commit 172b1a0
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 70 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ Social Stream Ninja (SSN) makes use of VDO.Ninja's data-transport API to stream
- IRC (via https://webchat.quakenet.org/)
- Tradingview.com (just the normal viewer page; no pop out)
- rooter.gg (no pop out; just pause the video I guess)
- loco.gg (no pop out; just pause the video I guess)
- loco.com (no pop out; just pause the video I guess)
- buzzit.ca (community member submitted integration)
- afreecatv.com (pop out the chat; you can't close the main window it seems tho?)
- nonolive.com (no pop out; partial support added so far only)
Expand Down
7 changes: 3 additions & 4 deletions ai.js
Original file line number Diff line number Diff line change
Expand Up @@ -1022,8 +1022,8 @@ async function processUserInput(userInput, data, additionalInstructions, botname

const ragDecision = await callOllamaAPI(ragPrompt);
const decision = parseDecision(ragDecision);

if (decision.needsSearch) {
console.log(decision);
if (decision.needsSearch && decision.searchQuery) {
const searchResults = await performLunrSearch(decision.searchQuery);
return await generateResponseWithSearchResults(userInput, searchResults, data.chatname, additionalInstructions);
} else {
Expand Down Expand Up @@ -1843,7 +1843,6 @@ async function loadLunrIndex() {
// log('Prepared documents for Lunr:', documents);

globalLunrIndex = initLunrIndex(documents);
log('Lunr index initialized');

return globalLunrIndex;
} catch (error) {
Expand All @@ -1870,7 +1869,7 @@ function initLunrIndex(documents) {
}
}, this);
} else {
log('No valid documents provided to initLunrIndex');
console.log('No valid documents provided to initLunrIndex');
}
});
}
Expand Down
59 changes: 29 additions & 30 deletions background.js
Original file line number Diff line number Diff line change
Expand Up @@ -4008,8 +4008,6 @@ function sendToS10(data, fakechat=false, relayed=false) {
if (data.chatmessage.includes(miscTranslations.said)){
return null;
}

const StageTEN_API_URL = "https://demo.stageten.tv/apis/plugin-service/chat/message/send"

let cleaned = data.chatmessage;
if (data.textonly){
Expand Down Expand Up @@ -4091,20 +4089,35 @@ function sendToS10(data, fakechat=false, relayed=false) {
}

// console.error(msg, fakechat);

let xhr = new XMLHttpRequest();
xhr.open("POST", StageTEN_API_URL);
xhr.setRequestHeader("content-type", "application/json");
xhr.setRequestHeader("x-s10-chat-api-key", settings.s10apikey.textsetting);
//xhr.withCredentials = true;
xhr.onload = function () {
//log(xhr.response);
};
xhr.onerror = function (e) {
//log("error sending to stageten");
};

xhr.send(JSON.stringify(msg));
try {
let xhr = new XMLHttpRequest();
xhr.open("POST", "https://demo.stageten.tv/apis/plugin-service/chat/message/send");
xhr.setRequestHeader("content-type", "application/json");
xhr.setRequestHeader("x-s10-chat-api-key", settings.s10apikey.textsetting);
//xhr.withCredentials = true;
xhr.onload = function () {
//log(xhr.response);
};
xhr.onerror = function (e) {
//log("error sending to stageten");
};
xhr.send(JSON.stringify(msg));
} catch(e){}

try {
let xhr2 = new XMLHttpRequest();
xhr2.open("POST", "https://app.stageten.tv/apis/plugin-service/chat/message/send");
xhr2.setRequestHeader("content-type", "application/json");
xhr2.setRequestHeader("x-s10-chat-api-key", settings.s10apikey.textsetting);
xhr2.onload = function () {
//log(xhr2.response);
};
xhr2.onerror = function (e) {
//log("error sending to stageten");
};
xhr2.send(JSON.stringify(msg));
} catch(e){}

} catch (e) {
console.warn(e);
}
Expand Down Expand Up @@ -6064,8 +6077,6 @@ async function sendMessageToTabs(data, reverse = false, metadata = null, relayMo
}
} else if (tab.url.startsWith("https://app.slack.com")) {
await attachAndChat(tab.id, data.response, true, true, true, false, overrideTimeout);
} else if (metadata && settings.fancystageten && tab.url.includes(".stageten.tv/channel")) {
handleFancyStageTen(tab.id, metadata);
} else if (tab.url.startsWith("https://app.zoom.us/")) {
await attachAndChat(tab.id, data.response, false, true, false, false, overrideTimeout, zoomFakeChat);
continue;
Expand Down Expand Up @@ -6191,18 +6202,6 @@ function handleStageTen(tab, data, metadata) {
}
}

// Helper function to handle fancy StageTen
function handleFancyStageTen(tabId, metadata) {
try {
log("SENDING ORIGINAL RAW DATA TO S10");
chrome.tabs.sendMessage(tabId, { metadata: metadata }, function (response = false) {
chrome.runtime.lastError;
});
} catch (e) {
console.error(e);
}
}

// Helper function to attach debugger and send chat
async function attachAndChat(tabId, message, middle, keypress, backspace, delayedPress, overrideTimeout, chatFunction = generalFakeChat) {
return new Promise((resolve, reject) => {
Expand Down
74 changes: 48 additions & 26 deletions landing.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
<link rel="icon" type="image/x-icon" href="./icons/favicon.ico">
<link rel="stylesheet" href="styles.css">
<script async defer src="./thirdparty/buttons.js"></script>
<script src="./thirdparty/marked.umd.min.js"></script>
<script src="./thirdparty/index.umd.min.js"></script>
<meta property="og:title" content="Social Stream Ninja | Enhance Your Live Streaming">
<meta property="og:description" content="Easily integrate chat messages from various platforms like YouTube, Twitch, and Facebook into your live streams with Social Stream Ninja.">
<meta property="og:url" content="https://socialstream.ninja">
Expand Down Expand Up @@ -934,36 +932,60 @@ <h3 id="contributors-to-this-project">Contributors to this project</h3>
});
}

const REQUIRED_SCRIPTS = [
'./thirdparty/marked.umd.min.js',
'./thirdparty/index.umd.min.js'
];

function loadScripts(scripts, callback) {
let loaded = 0;
scripts.forEach(src => {
const script = document.createElement('script');
script.src = src;
script.onload = () => {
loaded++;
if (loaded === scripts.length) callback();
};
document.head.appendChild(script);
});
}

if (location.protocol.startsWith('http')) {
document.addEventListener("DOMContentLoaded", () => {
if (typeof marked === 'undefined' || typeof markedGfmHeadingId === 'undefined') {
console.error('Required libraries (marked or markedGfmHeadingId) not loaded');
return;
loadScripts(REQUIRED_SCRIPTS, () => {
const gfmHeading = markedGfmHeadingId.gfmHeadingId();
gfmHeading.name = 'gfm-heading-id';

marked.setOptions({
headerIds: true,
mangle: false
});

marked.use({ extensions: [gfmHeading] });

fetch('./README.md')
.then(response => {
if (!response.ok) throw new Error('Failed to fetch README.md');
return response.text();
})
.then(text => {
document.getElementById('markdown').innerHTML = marked.parse(text);
if (window.location.hash) {
scrollToAnchor(window.location.hash);
}
})
.catch(error => console.error('Error loading the README:', error));

window.addEventListener('hashchange', () => {
if (window.location.hash) {
scrollToAnchor(window.location.hash);
}

marked.use(markedGfmHeadingId.gfmHeadingId({}));

fetch('./README.md')
.then(response => {
if (!response.ok) throw new Error('Failed to fetch README.md');
return response.text();
})
.then(text => {
console.log(text);
document.getElementById('markdown').innerHTML = marked.parse(text);
if (window.location.hash) {
scrollToAnchor(window.location.hash);
}
})
.catch(error => console.error('Error loading the README:', error));
});
});
});
}

window.addEventListener('hashchange', () => {
if (window.location.hash) {
scrollToAnchor(window.location.hash);
}
});

</script>
</body>
</html>
7 changes: 5 additions & 2 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.9.3",
"version": "3.9.4",
"homepage_url": "http://socialstream.ninja/",
"icons": {
"128": "icons/icon-128.png"
Expand Down Expand Up @@ -138,6 +138,9 @@
"https://www.tradingview.com/streams/*",
"https://app.chime.aws/meetings/*",
"https://*.loco.gg/*",
"https://loco.gg/*",
"https://*.loco.com/*",
"https://loco.com/*",
"https://joystick.tv/u/*/chat",
"https://www.buzzit.ca/event/*/chat",
"https://*.floatplane.com/popout/livechat",
Expand Down Expand Up @@ -361,7 +364,7 @@
},
{
"js": [ "./sources/loco.js" ],
"matches": [ "https://*.loco.gg/*" ]
"matches": [ "https://*.loco.gg/*", "https://loco.gg/streamers/*", "https://*.loco.com/*", "https://loco.com/streamers/*" ]
},
{
"js": [ "./sources/joystick.js" ],
Expand Down
8 changes: 1 addition & 7 deletions popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -4020,13 +4020,7 @@ <h3><span data-translate="misc-chat-options">Miscellaneous options for sites</sp
</label>
<img class="icon" src="./sources/images/twitter.png" style="display: inline-block;" /> <span data-translate="twitter-brand-instead-of-x">Use Twitter branding instead of X</span>
</div>
<div title="Experimental demo options for Stage TEN">
<label class="switch">
<input type="checkbox" data-setting="fancystageten" />
<span class="slider round"></span>
</label>
<img class="icon" src="./sources/images/stageten.png" style="display: inline-block;" /> <span data-translate="enable-demo-option-for-stageten">Stage TEN demo feature mode</span>
</div>

<div title="Flip Youtube watch page layout">
<label class="switch">
<input type="checkbox" data-setting="flipYoutube" />
Expand Down

0 comments on commit 172b1a0

Please sign in to comment.