|
var videos = document.querySelectorAll('video'); |
|
var result = ''; |
|
|
|
Array.prototype.forEach.call(videos, function(video, i) { |
|
// direct source |
|
if (video.getAttribute('src') !== null) { |
|
result += video.getAttribute('src') + '\n-------------------------\n'; |
|
} |
|
|
|
// check multiple <source>-tags |
|
var sources = video.querySelectorAll('source[src]'); |
|
Array.prototype.forEach.call(sources, function(source, j) { |
|
if (source.getAttribute('src') !== null) { |
|
result += source.getAttribute('src') + '\n-------------------------\n'; |
|
} |
|
}); |
|
}); |
|
|
|
// create a popup and style it... |
|
var popup = document.createElement("div"); |
|
popup.setAttribute('style', 'font-size: 11px; font-family: Helvetica, Arial, sans-serif; line-height: 1; padding: 10px; position: fixed; top: 70px; right: 10px; z-index: 99999; background: #fff; width: 400px; height: 200px; overflow: hidden;border: 1px solid #ccc;'); |
|
document.body.appendChild(popup); |
|
|
|
// add links to textarea and add textarea to popup |
|
var textarea = document.createElement("textarea"); |
|
textarea.setAttribute('style', 'width: 100%; height: 160px;font-size: 11px; font-family: Helvetica, Arial, sans-serif; line-height: 1;'); |
|
textarea.value = "Found HTML5 video sources:\n=====================================\n\n" + result; |
|
|
|
popup.appendChild(textarea); |
|
|
|
// add links to textarea and add textarea to popup |
|
var closeBtn = document.createElement("button"); |
|
closeBtn.innerHTML = "Close"; |
|
// add option to close this... |
|
closeBtn.addEventListener('click', function() { |
|
popup.remove(); |
|
}) |
|
|
|
popup.appendChild(closeBtn); |