Last active
April 26, 2018 12:12
-
-
Save dan-dr/5188f7e58bbfbc93b7a3fecdc79a4a21 to your computer and use it in GitHub Desktop.
Find m3u8 streams for streamlink bookmarklet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript:(function (d) { | |
function guid() { | |
function s4() { | |
return Math.floor((1 + Math.random()) * 0x10000) | |
.toString(16) | |
.substring(1); | |
} | |
return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4(); | |
} | |
function getUrls(element) { | |
return element.innerHTML.match(/(?:(?:https?|ftp|file):\/\/|www\.|ftp\.)(?:\([-A-Z0-9+&@#\/%=~_|$?&!:,.]*\)|[-A-Z0-9+&@#\/%=~_|$?!:,.])*(?:\([-A-Z0-9+&@#\/%=~_|$?!:,.]*\)|[A-Z0-9+&@#\/%=~_|$])/igm).filter(url => ~url.indexOf(".m3u8")) | |
} | |
var frames = document.getElementsByTagName("iframe"); | |
var urls = []; | |
try { | |
for (var i = 0; i < frames.length; i++) { | |
var f = frames[i].contentDocument; | |
getUrls(f.documentElement) | |
} | |
} catch (e) {} | |
var urls = urls.concat(getUrls(document.documentElement)); | |
var s = d.createElement('div'); | |
s.id = "a"+guid(); | |
s.style = 'position: relative; top: 0; right: 0; z-index: 99999999;'; | |
s.innerHTML = urls.map(u => `<div><a href=${u}>${u}</a></div>`).join('') + `<button onclick="javascript:(function(){document.querySelector('#${s.id}').outerHTML=''})()">Close</button>`; | |
d.body.insertBefore(s, d.body.firstChild); | |
})(document) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Gist doesn't support javascript links, so just drag and drop this: Find Streams and then manually edit the bookmark url (copy and paste the code above)