From 2db8023e8ae64a5dea227de1cbae2f1edefd250b Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Sun, 3 Jul 2016 17:03:18 +0200 Subject: [PATCH] Add simplistic readable-mode buffer mode --- conkeror/.conkerorrc/readable-mode.css | 18 ++++++++++++++++++ conkeror/.conkerorrc/readable.js | 26 ++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 conkeror/.conkerorrc/readable-mode.css create mode 100644 conkeror/.conkerorrc/readable.js diff --git a/conkeror/.conkerorrc/readable-mode.css b/conkeror/.conkerorrc/readable-mode.css new file mode 100644 index 0000000..0b5d98a --- /dev/null +++ b/conkeror/.conkerorrc/readable-mode.css @@ -0,0 +1,18 @@ +body { + background-color: #ffffff; + color: #000000; + width: 750px; + margin: 0 auto; + font-family: Signika; + font-size: 16px; + text-align: left; +} + +body img { + max-width: 750px; +} + +pre, code, tt { + font-family: "Fantasque Sans Mono"; + font-size: 16px; +} diff --git a/conkeror/.conkerorrc/readable.js b/conkeror/.conkerorrc/readable.js new file mode 100644 index 0000000..97a4904 --- /dev/null +++ b/conkeror/.conkerorrc/readable.js @@ -0,0 +1,26 @@ +/*global define_buffer_mode make_file read_text_file make_css_data_uri */ + +var readable_load_path = this.loading_paths[0]; + +function readable_mode_enable(buffer) { + var path = readable_load_path + '/readable-mode.css'; + var file = make_file(path); + var styles = read_text_file(file); + var document = buffer.document; + var newCSS = document.createElement('link'); + var uri = make_css_data_uri([styles]); + + newCSS.id = 'readable-mode-css'; + newCSS.rel = 'stylesheet'; + newCSS.href = uri.spec; + + document.getElementsByTagName('head')[0].appendChild(newCSS); +} + +function readable_mode_disable(buffer) { + var newCSS = buffer.document.getElementById('readable-mode-css'); + buffer.document.getElementsByTagName('head')[0].removeChild(newCSS); +} + +define_buffer_mode('readable-mode', readable_mode_enable, readable_mode_disable, + $doc = 'Make the current buffer readable.');