Skip to content

Commit abca62b

Browse files
committed
block viewer counts for open sites
1 parent 42e3b3b commit abca62b

File tree

1 file changed

+27
-7
lines changed

1 file changed

+27
-7
lines changed

background.js

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5073,13 +5073,18 @@ async function sendToDestinations(message) {
50735073
var viewerCounts = {};
50745074
for (const [tid, tabData] of metaDataStore) {
50755075
if (tabData.viewer_update && tabData.viewer_update.type){
5076+
// Skip viewer counts from sites that are not opted-in
5077+
if (!checkIfAllowed(tabData.viewer_update.type)) {
5078+
continue;
5079+
}
5080+
50765081
let count = parseInt(tabData.viewer_update.meta) || 0;
5077-
5082+
50785083
// Pump the numbers if enabled
50795084
if (settings.pumpTheNumbers) {
50805085
count = Math.round(count * 1.75);
50815086
}
5082-
5087+
50835088
viewerCounts[tabData.viewer_update.type] = (viewerCounts[tabData.viewer_update.type] || 0) + count;
50845089
}
50855090
}
@@ -8009,18 +8014,26 @@ function updateViewerCount(data) {
80098014
viewerCounts = {};
80108015
lastUpdated = {};
80118016
activeViewerSources = {};
8012-
8017+
80138018
// Process each platform's viewer count
80148019
Object.keys(data.meta).forEach(type => {
8020+
// Skip viewer counts from sites that are not opted-in
8021+
if (!checkIfAllowed(type)) {
8022+
return;
8023+
}
80158024
viewerCounts[type] = parseInt(data.meta[type]) || 0;
80168025
lastUpdated[type] = Date.now();
80178026
if (viewerCounts[type] > 0) {
80188027
activeViewerSources[type] = true;
80198028
}
80208029
});
8021-
}
8030+
}
80228031
// Handle legacy single viewer_update format
80238032
else if (data.type && ("meta" in data)) {
8033+
// Skip viewer counts from sites that are not opted-in
8034+
if (!checkIfAllowed(data.type)) {
8035+
return;
8036+
}
80248037
const sourceKey = data.tid ? `${data.type}-${data.tid}` : data.type;
80258038
viewerCounts[sourceKey] = parseInt(data.meta) || 0;
80268039
lastUpdated[sourceKey] = Date.now();
@@ -8086,15 +8099,22 @@ function processHype2() {
80868099

80878100
function combineHypeData() {
80888101
const result = { chatters: {}, viewers: {}, combined: {} };
8089-
8090-
// Copy active chatters data
8102+
8103+
// Copy active chatters data (only from opted-in sources)
80918104
for (const sourceType in hype) {
8105+
if (!checkIfAllowed(sourceType)) {
8106+
continue;
8107+
}
80928108
result.chatters[sourceType] = hype[sourceType];
80938109
if (!result.combined[sourceType]) result.combined[sourceType] = { chatters: 0, viewers: 0 };
80948110
result.combined[sourceType].chatters = hype[sourceType];
80958111
}
8096-
8112+
80978113
for (const sourceType in viewerCounts) {
8114+
// Skip sources that are not opted-in
8115+
if (!checkIfAllowed(sourceType)) {
8116+
continue;
8117+
}
80988118
// Include all sources that have viewer data, even if 0
80998119
result.viewers[sourceType] = viewerCounts[sourceType];
81008120
if (!result.combined[sourceType]) {

0 commit comments

Comments
 (0)