Skip to content

Commit

Permalink
twitch-embed: Do nothing if the location hash is not set.
Browse files Browse the repository at this point in the history
  • Loading branch information
stefansundin committed May 6, 2024
1 parent 101164e commit d1432f5
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions views/twitch-embed.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!doctype html>
<!DOCTYPE html>
<html>
<head>
<style>
Expand All @@ -16,21 +16,23 @@
<noscript>Please enable JavaScript.</noscript>

<script>
let qs = window.location.hash.substr(1);
qs += `&parent=${window.location.hostname}`;
if (document.referrer !== "") {
const referrer = new URL(document.referrer);
qs += `&parent=${referrer.hostname}`;
}
if (window.location.hash) {
let qs = window.location.hash.substr(1);
qs += `&parent=${window.location.hostname}`;
if (document.referrer) {
const referrer = new URL(document.referrer);
qs += `&parent=${referrer.hostname}`;
}

const iframe = document.createElement("iframe");
iframe.width = "100%";
iframe.height = "100%";
iframe.frameBorder = "0";
iframe.scrolling = "no";
iframe.allowFullscreen = true;
iframe.src = `https://player.twitch.tv/?${qs}`;
document.body.appendChild(iframe);
const iframe = document.createElement('iframe');
iframe.width = '100%';
iframe.height = '100%';
iframe.frameBorder = '0';
iframe.scrolling = 'no';
iframe.allowFullscreen = true;
iframe.src = `https://player.twitch.tv/?${qs}`;
document.body.appendChild(iframe);
}
</script>
</body>
</html>

0 comments on commit d1432f5

Please sign in to comment.