-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
63 lines (59 loc) · 1.33 KB
/
index.html
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
53
54
55
56
57
58
59
60
61
62
63
<!DOCTYPE html>
<html>
<head>
<style>
iframe {
width: 90%;
height: 200px;
display: block;
margin: 0 auto;
padding: 10px;
}
</style>
<script type="module">
window.addIFrame = function (href) {
const div = document.createElement('div')
document.body.appendChild(div)
const a = document.createElement('a')
a.href = href
var src;
if (
a.hostname.includes('youtube.com')
) {
if (a.pathname.includes('watch')) {
src = `${a.protocol}//www.youtube-nocookie.com/embed/${a.search.substr(3)}?mute=1`
} else if (a.pathname.includes('embed')) {
src = `${href}?mute=1`
}
} else if (
a.hostname.includes('youtu.be')
) {
src = `${a.protocol}//www.youtube-nocookie.com/embed/${a.pathname}?mute=1`
} else if (
a.hostname.includes('soundcloud')
) {
console.log('soundcloud - make sure to use the embed thing in FF and pasteIFrame !')
} else if (
a.hostname.includes('bandcamp')
) {
// this works, but could do better
src = href
}
console.log(src)
if (src) {
div.innerHTML = `<iframe src="${src}"></iframe>`
} else {
console.error('ERROR', src)
}
};
window.pasteIFrame = function(iframe) {
const div = document.createElement('div')
document.body.appendChild(div)
div.innerHTML = iframe
}
</script>
</head>
<body>
<!-- iframes go here -->
</body>
</html>