Skip to content

Commit f1cf350

Browse files
committed
fix(gif): restore copied source filtering
1 parent 78f5f22 commit f1cf350

2 files changed

Lines changed: 26 additions & 9 deletions

File tree

gif.html

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@
6565
const mediaContent = document.getElementById('mediaContent');
6666
const customGifFilterId = (urlParams.get('gifid') || '').trim();
6767
const customGifFilterCommand = (urlParams.get('gifcommand') || '').trim().toLowerCase();
68+
const customGifFilterCommands = customGifFilterCommand.split(',').map(function(command) {
69+
return command.trim();
70+
}).filter(Boolean);
6871
if (urlParams.has('stretch')) document.body.classList.add('stretch');
6972
let mediaQueue = [];
7073
let isPlaying = false;
@@ -104,23 +107,29 @@
104107
const mediaProbeTimeout = 4000;
105108

106109
function shouldShowCustomGifData(data) {
107-
if (!customGifFilterId && !customGifFilterCommand) return true;
110+
if (!customGifFilterId && !customGifFilterCommands.length) return true;
108111

109112
const meta = data && data.meta ? data.meta : {};
110113
if (customGifFilterId && String(meta.customGifCommandId || '') === customGifFilterId) {
111114
return true;
112115
}
113116

114-
if (customGifFilterCommand) {
117+
if (customGifFilterCommands.length) {
115118
const command = String(meta.customGifCommand || '').toLowerCase();
116-
if (command === customGifFilterCommand) return true;
119+
if (customGifFilterCommands.indexOf(command) !== -1) return true;
117120

118121
const commands = Array.isArray(meta.customGifCommands) ? meta.customGifCommands : [];
119122
for (let i = 0; i < commands.length; i++) {
120-
if (String(commands[i] || '').toLowerCase() === customGifFilterCommand) {
123+
if (customGifFilterCommands.indexOf(String(commands[i] || '').toLowerCase()) !== -1) {
121124
return true;
122125
}
123126
}
127+
128+
const chatMessage = String(data && data.chatmessage ? data.chatmessage : '').trim().toLowerCase();
129+
const firstWord = chatMessage.split(/\s+/)[0] || '';
130+
if (customGifFilterCommands.indexOf(firstWord) !== -1 || customGifFilterCommands.indexOf(chatMessage) !== -1) {
131+
return true;
132+
}
124133
}
125134

126135
return false;
@@ -536,7 +545,7 @@
536545

537546
const iframe = document.createElement("iframe");
538547
const filename = new URL(window.location.href).pathname.split('/').pop().split('.')[0] || "dock";
539-
const bridgeLabel = (customGifFilterId || urlParams.get('label') || filename).trim() || filename;
548+
const bridgeLabel = ((customGifFilterId || customGifFilterCommand) ? filename : (urlParams.get('label') || filename)).trim() || filename;
540549
const password = urlParams.get('password') || 'false';
541550
const lanonly = urlParams.has('lanonly') ? '&lanonly' : '';
542551
iframe.src = "https://vdo.socialstream.ninja/?ln&salt=vdo.ninja&notmobile&notmobile&password=" + encodeURIComponent(password) + lanonly + "&solo&view=" + urlParams.get('session') + "&novideo&noaudio&label=" + encodeURIComponent(bridgeLabel) + "&cleanoutput&room=" + urlParams.get('session');

popup.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6066,12 +6066,18 @@ function getCustomGifCommandSourceUrl(entry) {
60666066

60676067
const commandInput = entry?.querySelector('.custom-command');
60686068
const mediaUrlInput = entry?.querySelector('.custom-media-url');
6069-
const id = getCustomGifCommandEntryId(commandInput?.value?.trim() || '', mediaUrlInput?.value?.trim() || '', entry?.dataset.commandId);
6069+
const command = commandInput?.value?.trim() || '';
6070+
const id = getCustomGifCommandEntryId(command, mediaUrlInput?.value?.trim() || '', entry?.dataset.commandId);
60706071
if (entry) entry.dataset.commandId = id;
60716072

60726073
url = removeQueryParamWithValue(url, 'gifid');
60736074
url = removeQueryParamWithValue(url, 'gifcommand');
6074-
return cleanURL(updateURL('gifid=' + encodeURIComponent(id), url));
6075+
url = updateURL('gifid=' + encodeURIComponent(id), url);
6076+
const aliases = getCustomGifCommandAliases(command);
6077+
if (aliases.length) {
6078+
url = updateURL('gifcommand=' + encodeURIComponent(aliases.join(',')), url);
6079+
}
6080+
return cleanURL(url);
60756081
}
60766082

60776083
function copyCustomGifCommandSource(entry, button) {
@@ -7117,7 +7123,7 @@ function triggerCustomGifPreview(entry) {
71177123
return;
71187124
}
71197125

7120-
chrome.runtime.sendMessage({
7126+
const payload = {
71217127
cmd: 'previewCustomGif',
71227128
target: 'gif',
71237129
type: 'popup',
@@ -7129,7 +7135,9 @@ function triggerCustomGifPreview(entry) {
71297135
customGifCommand: getCustomGifCommandAliases(command)[0] || command,
71307136
customGifCommands: getCustomGifCommandAliases(command)
71317137
}
7132-
}, function () {});
7138+
};
7139+
chrome.runtime.sendMessage(payload, function () {});
7140+
chrome.runtime.sendMessage(Object.assign({}, payload, { target: id }), function () {});
71337141
}
71347142

71357143
function createCommandEntry(command = '', url = '', id = '') {

0 commit comments

Comments
 (0)