-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnativeplayer.js
More file actions
33 lines (28 loc) · 934 Bytes
/
nativeplayer.js
File metadata and controls
33 lines (28 loc) · 934 Bytes
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
(function() {
'use strict';
// Function to inject the script into an iframe
function injectScript(iframe, scriptContent) {
const iframeDoc = iframe.contentDocument;
const script = document.createElement('script');
script.textContent = scriptContent;
iframeDoc.head.appendChild(script);
}
// Script to force the native player
const nativePlayerScript = `
(function() {
'use strict';
// Set the 'playsinline' attribute to prevent full-screen mode
const video = document.querySelector('video');
video.setAttribute('playsinline', '');
// Trigger the native player
video.load();
}
)();
`;
// Find all iframe elements containing videos
const iframes = document.querySelectorAll('iframe[src*="video"]');
// Loop through each iframe and inject the script
iframes.forEach(iframe => {
injectScript(iframe, nativePlayerScript);
});
})();