Skip to content

Instantly share code, notes, and snippets.

@AnatoliyLitinskiy
Created July 13, 2018 11:14
Show Gist options
  • Save AnatoliyLitinskiy/5ba97188266dfcbfd7caf6511f971be0 to your computer and use it in GitHub Desktop.
Save AnatoliyLitinskiy/5ba97188266dfcbfd7caf6511f971be0 to your computer and use it in GitHub Desktop.
screencast preview
(function() {
const links = document.getElementsByTagName('a');
for (let i = 0; i < links.length; i++) {
const a = links.item(i);
if (a.href && a.href.search('screencast.com') >= 0) {
console.log('screencast link', i, a);
let ifrFound = false;
for (let j = 0; j < a.childNodes.length; j++) {
if (a.childNodes.item(j).nodeName === 'IFRAME') {
ifrFound = true;
break;
}
}
if (ifrFound) continue;
const ifr = document.createElement('iframe');
ifr.setAttribute('width', 500);
ifr.setAttribute('height', 400);
ifr.setAttribute('src', a.href);
a.appendChild(ifr);
} else {
console.log('just link', i, a.href);
}
}
console.log('links', links);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment