Skip to content

Commit

Permalink
Add possibility to ignore sub gifts, remove hosts
Browse files Browse the repository at this point in the history
  • Loading branch information
justlx committed Dec 30, 2023
1 parent 9c8e691 commit 74c953c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 37 deletions.
15 changes: 3 additions & 12 deletions StreamMarathon/widget.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
//MULTIPLIERS:
let fieldData;

let maxTime = new Date(); // Time cap you want to use
Expand Down Expand Up @@ -39,9 +38,7 @@ function countdown(seconds, forced = false) {
if (paused) {
$('#countdown').countdown('pause');
}

saveState();

}

const pauseTimer = () => {
Expand Down Expand Up @@ -115,6 +112,9 @@ window.addEventListener('onEventReceived', function (obj) {
if (listener === 'follower-latest') {
if (fieldData.followSeconds !== 0) countdown(fieldData.followSeconds);
} else if (listener === 'subscriber-latest') {
if (data.sender && fieldData.subIgnoreGifts) {
return;
}
if (data.bulkGifted) { // Ignore gifting event and count only real subs
return;
}
Expand All @@ -125,12 +125,6 @@ window.addEventListener('onEventReceived', function (obj) {
} else {
if (fieldData.sub1Seconds !== 0) countdown(fieldData.sub1Seconds);
}

} else if (listener === 'host-latest') {
if (data['amount'] < fieldData.hostMin || fieldData.hostSeconds === 0) {
return;
}
countdown(fieldData.hostSeconds * data["amount"]);
} else if (listener === 'raid-latest') {
if (data['amount'] < fieldData.raidMin || fieldData.raidSeconds === 0) {
return;
Expand All @@ -152,8 +146,6 @@ window.addEventListener('onEventReceived', function (obj) {
}
countdown(parseInt(fieldData.merchSeconds * data["amount"]));
}


});
window.addEventListener('onWidgetLoad', function (obj) {
fieldData = obj.detail.fieldData;
Expand All @@ -163,7 +155,6 @@ window.addEventListener('onWidgetLoad', function (obj) {
loadState();
});


function saveState() {
if (paused) {
pausedSeconds = Math.round((start - new Date()) / 1000);
Expand Down
42 changes: 17 additions & 25 deletions StreamMarathon/widget.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,91 +103,83 @@
"label": "Seconds per follower:",
"value": 1,
"step": 1,
"group": "Event time settings"
"group": "Follower time settings"
},
"sub1Seconds": {
"type": "number",
"label": "Seconds per T1/Prime subscriber:",
"value": 60,
"step": 1,
"group": "Event time settings"
"group": "Sub time settings"
},
"sub2Seconds": {
"type": "number",
"label": "Seconds per T2 subscriber:",
"value": 120,
"step": 1,
"group": "Event time settings"
"group": "Sub time settings"
},
"sub3Seconds": {
"type": "number",
"label": "Seconds per T3 subscriber:",
"value": 180,
"step": 1,
"group": "Event time settings"
"group": "Sub time settings"
},
"subIgnoreGifts": {
"type": "checkbox",
"label": "Ignore gifted subs",
"value": false,
"group": "Sub time settings"
},
"cheerSeconds": {
"type": "number",
"label": "Seconds per 100 Bits:",
"value": 60,
"step": 0.1,
"group": "Event time settings"
"group": "Cheer time settings"
},
"cheerMin": {
"type": "number",
"label": "Minimum bits to trigger:",
"value": 100,
"step": 1,
"group": "Event time settings"
"group": "Cheer time settings"
},
"tipSeconds": {
"type": "number",
"label": "Seconds multiplied by tip amount:",
"value": 300,
"step": 0.01,
"group": "Event time settings"
"group": "Tip time settings"
},
"tipMin": {
"type": "number",
"label": "Minimum tip to trigger:",
"value": 1,
"step": 0.01,
"group": "Event time settings"
"group": "Tip time settings"
},
"merchSeconds": {
"type": "number",
"label": "Seconds multiplied by merch order amount:",
"value": 300,
"step": 0.01,
"group": "Event time settings"
},
"hostSeconds": {
"type": "number",
"label": "Seconds per viewer from host:",
"value": 1,
"step": 0.01,
"group": "Event time settings"
},
"hostMin": {
"type": "number",
"label": "Minimum viewers in host:",
"value": 100,
"step": 1,
"group": "Event time settings"
"group": "Merch time settings"
},
"raidSeconds": {
"type": "number",
"label": "Seconds per viewer from raid:",
"value": 0,
"step": 0.01,
"group": "Event time settings"
"group": "Raid time settings"
},
"raidMin": {
"type": "number",
"label": "Minimum viewers in raid:",
"value": 100,
"step": 1,
"group": "Event time settings"
"group": "Raid time settings"
},
"textAlign": {
"label": "Text align",
Expand Down

0 comments on commit 74c953c

Please sign in to comment.