Skip to content

Commit

Permalink
Include original favicon in HTTP server responses
Browse files Browse the repository at this point in the history
  • Loading branch information
tombh committed Jun 26, 2018
1 parent 2e1de9d commit 642fd83
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
16 changes: 14 additions & 2 deletions webext/src/dom/serialise_mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,28 +50,40 @@ export default (MixinBase) => class extends MixinBase {
let info = '';
const head = this._getHTMLHead();
const date_time = this._getCurrentDataTime();
info += "\n\n" + `Built by <a href="https://www.brow.sh">Browsh</a> on ${date_time}`;
const elapsed = `${performance.now() - this._raw_text_start}ms`;
info += "\n\n" + `Built by <a href="https://www.brow.sh">Browsh</a> ` +
`on ${date_time} in ${elapsed}`;
if (this.dimensions.is_page_truncated) {
info += '\nBrowsh parser: the page was too large, some text may have been truncated.';
}
const foot = `${info}</pre></body></html>`;
const foot = `<span class="browsh-footer">${info}</span></pre></body></html>`;
return head + raw_text + foot;
}

_getHTMLHead() {
return `<html>
<head>
${this._getFavicon()}
<title>${document.title}</title>
<style>
html * {
font-family: monospace;
}
.browsh-footer {
opacity: 0.7;
}
</style>
</head>
<body>
<pre>`;
}

_getFavicon() {
let el = document.querySelector("link[rel*='icon']");
return `<link rel="shortcut icon" type = "image/x-icon" href="${el.href}">`
}


_getCurrentDataTime() {
let current_date = new Date();
const offset = -(new Date().getTimezoneOffset() / 60);
Expand Down
1 change: 1 addition & 0 deletions webext/src/dom/text_builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export default class extends utils.mixins(CommonMixin, SerialiseMixin) {
}

sendRawText(type) {
this._raw_text_start = performance.now();
this._raw_mode_type = type;
// TODO:
// The presence of the `getScreenshotWithText()` and `setTimeout()` calls are a hack
Expand Down

0 comments on commit 642fd83

Please sign in to comment.