mirror of
https://github.com/webrecorder/pywb.git
synced 2025-03-24 06:59:52 +01:00
vidrw: work on yt rewrite
This commit is contained in:
parent
50cae15663
commit
07bcf9fbfe
@ -41,6 +41,15 @@ __wbvidrw = (function() {
|
|||||||
already_checked = true;
|
already_checked = true;
|
||||||
check_replacement(embeds[i], embeds[i].getAttribute("src"));
|
check_replacement(embeds[i], embeds[i].getAttribute("src"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (wbinfo.url.indexOf("://www.youtube.com/watch") > 0) {
|
||||||
|
var ytvideo = document.getElementsByTagName("video");
|
||||||
|
if (ytvideo.length == 1) {
|
||||||
|
if (ytvideo[0].getAttribute("data-youtube-id") != "") {
|
||||||
|
check_replacement(ytvideo[0], wbinfo.url);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function check_replacement(elem, src) {
|
function check_replacement(elem, src) {
|
||||||
@ -48,6 +57,10 @@ __wbvidrw = (function() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (src.indexOf("javascript:") == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
src = _wb_wombat.extract_orig(src);
|
src = _wb_wombat.extract_orig(src);
|
||||||
|
|
||||||
var xhr = new XMLHttpRequest();
|
var xhr = new XMLHttpRequest();
|
||||||
@ -66,9 +79,24 @@ __wbvidrw = (function() {
|
|||||||
var video_url = video_info.url;
|
var video_url = video_info.url;
|
||||||
video_url = wbinfo.prefix + video_url;
|
video_url = wbinfo.prefix + video_url;
|
||||||
|
|
||||||
|
var tag = elem.tagName.toLowerCase();
|
||||||
console.log("REPLACING: " + video_url);
|
console.log("REPLACING: " + video_url);
|
||||||
var width = elem.getAttribute("width");
|
|
||||||
var height = elem.getAttribute("height");
|
var width, height;
|
||||||
|
|
||||||
|
if (tag == "video") {
|
||||||
|
elem = elem.parentNode;
|
||||||
|
elem = elem.parentNode;
|
||||||
|
|
||||||
|
width = elem.clientWidth;
|
||||||
|
height = elem.clientHeight;
|
||||||
|
|
||||||
|
elem = elem.parentNode;
|
||||||
|
//elem.parentNode.setAttribute("id", "_wb_vid");
|
||||||
|
} else {
|
||||||
|
width = elem.clientWidth;
|
||||||
|
height = elem.clientHeight;
|
||||||
|
}
|
||||||
|
|
||||||
console.log(video_info.ext);
|
console.log(video_info.ext);
|
||||||
|
|
||||||
@ -94,15 +122,17 @@ __wbvidrw = (function() {
|
|||||||
console.log("html5 video success");
|
console.log("html5 video success");
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log(elem.tagName);
|
if (tag == "iframe") {
|
||||||
|
|
||||||
if (elem.tagName.toLowerCase() == "iframe") {
|
|
||||||
elem.parentNode.replaceChild(htmlvideo, elem);
|
elem.parentNode.replaceChild(htmlvideo, elem);
|
||||||
} else if (elem.tagName.toLowerCase() == "embed") {
|
} else if (tag == "embed") {
|
||||||
if (elem.parentNode && elem.parentElement.tagName.toLowerCase() == "object") {
|
if (elem.parentNode && elem.parentElement.tagName.toLowerCase() == "object") {
|
||||||
elem = elem.parentNode;
|
elem = elem.parentNode;
|
||||||
}
|
}
|
||||||
elem.parentNode.replaceChild(htmlvideo, elem);
|
elem.parentNode.replaceChild(htmlvideo, elem);
|
||||||
|
} else if (tag == "video") {
|
||||||
|
// elem = elem.parentNode;
|
||||||
|
// elem = elem.parentNode;
|
||||||
|
elem.parentNode.replaceChild(htmlvideo, elem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user