-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathiframe-script.js
More file actions
52 lines (41 loc) · 1.86 KB
/
iframe-script.js
File metadata and controls
52 lines (41 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// This script gets injected into Vimeo iframes to help access content
console.log("Ridley Transcriptor iframe helper loaded");
// Find and click the transcript button
function findAndClickTranscriptButton() {
console.log("Looking for transcript button...");
// Look for buttons with text or aria-label containing "transcript" or "cc"
const buttons = Array.from(document.querySelectorAll('button'));
// First, look for buttons with "transcript" in them
let transcriptBtn = buttons.find(btn =>
(btn.textContent && btn.textContent.toLowerCase().includes('transcript')) ||
(btn.getAttribute('aria-label') && btn.getAttribute('aria-label').toLowerCase().includes('transcript'))
);
// If not found, try buttons with "cc" or "caption" or "subtitle"
if (!transcriptBtn) {
transcriptBtn = buttons.find(btn =>
(btn.textContent && btn.textContent.toLowerCase().includes('cc')) ||
(btn.getAttribute('aria-label') && btn.getAttribute('aria-label').toLowerCase().includes('caption')) ||
(btn.getAttribute('aria-label') && btn.getAttribute('aria-label').toLowerCase().includes('subtitle'))
);
}
if (transcriptBtn) {
console.log("Found transcript button:", transcriptBtn);
transcriptBtn.click();
// Notify the parent window that the button was clicked
window.parent.postMessage({
action: 'transcriptButtonClicked',
success: true
}, '*');
return true;
}
console.log("Transcript button not found");
// Notify the parent window that the button was not found
window.parent.postMessage({
action: 'transcriptButtonClicked',
success: false,
error: 'Transcript button not found'
}, '*');
return false;
}
// Try immediately and then retry
setTimeout(findAndClickTranscriptButton, 500);