mirror of
https://github.com/webrecorder/pywb.git
synced 2025-03-24 06:59:52 +01:00
Page title and favicon display (#356)
Set favicon and title from top-most replay frame to the top frame (work from @Devhercule): Favicon display in no-proxy mode with framed_replay: true. When "iframe": "#replay_iframe", the icon of the tab in question is not visible (or a wrong icon is displayed provided from cache memor ) because of the presence of an added frame (#replay_iframe). The modification allows to get the replay_iframe favicon and pass it to the main frame to be correctly displayed in the tab. (see Issue #342)
This commit is contained in:
parent
538ce88abc
commit
dd76ed2818
@ -109,6 +109,23 @@ function ContentFrame(content_info) {
|
|||||||
|
|
||||||
this.handle_message = function(state) {
|
this.handle_message = function(state) {
|
||||||
var type = state.wb_type;
|
var type = state.wb_type;
|
||||||
|
|
||||||
|
if (type === 'load') {
|
||||||
|
window.document.title = state.title + ' ' + state.ts;
|
||||||
|
var head = document.querySelector('head');
|
||||||
|
var oldLink = document.querySelectorAll("link[rel*='icon']");
|
||||||
|
for (var i = 0; i < oldLink.length; i++) {
|
||||||
|
head.removeChild(oldLink[i]);
|
||||||
|
}
|
||||||
|
var len = state.icons.length;
|
||||||
|
for (var i = 0; i < len; i++) {
|
||||||
|
var icon = state.icons[i];
|
||||||
|
var link = document.createElement('link');
|
||||||
|
link.rel = icon.rel;
|
||||||
|
link.href = icon.href;
|
||||||
|
head.appendChild(link);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (type == "load" || type == "replace-url") {
|
if (type == "load" || type == "replace-url") {
|
||||||
this.set_url(state);
|
this.set_url(state);
|
||||||
|
@ -3619,15 +3619,26 @@ var _WBWombat = function($wbwindow, wbinfo) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var message = {
|
var icons = [];
|
||||||
"url": $wbwindow.WB_wombat_location.href,
|
var hicons = $wbwindow.document.querySelectorAll("link[rel*='icon']");
|
||||||
"ts": wbinfo.timestamp,
|
for (var i = 0; i < hicons.length; i++) {
|
||||||
"request_ts": wbinfo.request_ts,
|
var hicon = hicons[i];
|
||||||
"is_live": wbinfo.is_live,
|
icons.push({
|
||||||
"title": $wbwindow.document ? $wbwindow.document.title : "",
|
rel: hicon.rel,
|
||||||
"readyState": $wbwindow.document.readyState,
|
href: wb_getAttribute.call(hicon, 'href')
|
||||||
"wb_type": "load"
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var message = {
|
||||||
|
"icons": icons,
|
||||||
|
"url": $wbwindow.WB_wombat_location.href,
|
||||||
|
"ts": wbinfo.timestamp,
|
||||||
|
"request_ts": wbinfo.request_ts,
|
||||||
|
"is_live": wbinfo.is_live,
|
||||||
|
"title": $wbwindow.document ? $wbwindow.document.title : "",
|
||||||
|
"readyState": $wbwindow.document.readyState,
|
||||||
|
"wb_type": "load"
|
||||||
|
}
|
||||||
|
|
||||||
send_top_message(message);
|
send_top_message(message);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user