Skip to content

Instantly share code, notes, and snippets.

@yukimochi
Last active November 7, 2021 15:05
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yukimochi/c0f9b756188fefa6d01a89865446a740 to your computer and use it in GitHub Desktop.
Save yukimochi/c0f9b756188fefa6d01a89865446a740 to your computer and use it in GitHub Desktop.
YouTube Live -> VRChat-OSC-Bridge SuperChat Notifier.

YouTube Live -> VRChat-OSC-Bridge SuperChat Notifier.

VRChat にスパチャが過去1秒間に発生したかをOSCメッセージで毎秒送信するブックマークレット (VRChat OSC Bridge 専用ツール)

説明

VRChat OSC Bridge が起動している状態で、 YouTube Live のコメント欄をポップアウトし、そのウィンドウに対して spc_to_osc.min.jsjavascript: 以降のコードを入力します。

実行すると、 所定のOSCメッセージが毎秒 /VRC_OSC/SPC に送信されます。

メッセージ内容

  • 過去一秒以内にスーパーチャットが発生した : 1
  • 過去一秒以内にスーパーチャットが発生しなかった : 0

注意

OSC Button In は、内容に変化がない場合、 Trigger を発動させることはありません。

関連

// Author: YUKIMOCHI
// Copyright (C) 2018 YUKIMOCHI MIT Licence
var p_id = [];
Array.prototype.slice.call(document.getElementsByTagName('yt-live-chat-paid-message-renderer')).forEach(function (n) {
p_id.push(n.getAttribute('id'));
});
function osc(a, m) {
var s = "127.0.0.1";
var p = "59000";
var x = new XMLHttpRequest();
x.open('POST', "http://" + s + ":" + p + a);
x.send(m);
}
function scs() {
setTimeout((osc('/VRC_OSC/SPC', 0)), 0);
Array.prototype.slice.call(document.getElementsByTagName('yt-live-chat-paid-message-renderer')).forEach(function (n) {
if (p_id.indexOf(n.getAttribute('id')) == -1) {
console.log('New SuperChat!');
setTimeout((osc('/VRC_OSC/SPC', 1)), 0);
p_id.push(n.getAttribute('id'));
}
});
setTimeout((function () { scs() }), 1000);
}
setTimeout((function () { scs() }), 1000);
// Author: YUKIMOCHI
// Copyright (C) 2018 YUKIMOCHI MIT Licence
javascript:setTimeout((function (){var p_id = []; Array.prototype.slice.call(document.getElementsByTagName('yt-live-chat-paid-message-renderer')).forEach(function (n) { p_id.push(n.getAttribute('id')); }); function osc(a, m) { var s = "127.0.0.1"; var p = "59000"; var x = new XMLHttpRequest(); x.open('POST', "http://" + s + ":" + p + a); x.send(m); } function scs() { setTimeout((osc('/VRC_OSC/SPC', 0)), 0); Array.prototype.slice.call(document.getElementsByTagName('yt-live-chat-paid-message-renderer')).forEach(function (n) { if (p_id.indexOf(n.getAttribute('id')) == -1) { console.log('New SuperChat!'); setTimeout((osc('/VRC_OSC/SPC', 1)), 0); p_id.push(n.getAttribute('id')); } }); setTimeout((function () { scs() }), 1000); } setTimeout((function () { scs() }), 1000);}),0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment