Collin J. Doering
939dfe0d54
- switched to conkeror-git from the AUR - changed font-size for mini-buffer and tabs - enabled adblock extension - added functions for browsing using a proxy Signed-off-by: Collin J. Doering <rekahsoft@gmail.com>
321 lines
12 KiB
Plaintext
Executable File
321 lines
12 KiB
Plaintext
Executable File
// File: ~/.conkerorrc
|
|
// Author: Collin J. Doering <rekahsoft@gmail.com>
|
|
// Date: Mar 27, 2011
|
|
|
|
// REKAHSOFT
|
|
|
|
// the default page for new buffers.
|
|
homepage = "http://www.duckduckgo.com";
|
|
|
|
// load urls from the command line in new buffers instead of new windows.
|
|
url_remoting_fn = load_url_in_new_buffer;
|
|
|
|
// load download buffers in the background in the current window, instead of in new windows.
|
|
download_buffer_automatic_open_target = OPEN_NEW_BUFFER_BACKGROUND;
|
|
|
|
// save a keystroke when selecting a dom node by number.
|
|
hints_auto_exit_delay = 500;
|
|
hints_ambiguous_auto_exit_delay = 3000;
|
|
|
|
// display properties of the current selected node during
|
|
// the hints interaction.
|
|
hints_display_url_panel = true;
|
|
|
|
// default directory for downloads and shell commands.
|
|
cwd = get_home_directory();
|
|
//cwd.append("downloads");
|
|
|
|
// set how conkeror will handle mime types
|
|
external_content_handlers = {
|
|
"*": "emacsclient -c",
|
|
text: { "*": "emacsclient -c" },
|
|
image: { "*": "feh --scale-down" },
|
|
video: { "*": "mplayer" },
|
|
audio: { "*": "mplayer" },
|
|
// "x-scheme-handler/magnet": "transmission-remote -a",
|
|
application: {
|
|
pdf: "zathura",
|
|
postscript: "zathura",
|
|
"x-dvi": "zathura",
|
|
"x-bittorrent": "transmission-remote -a"
|
|
}
|
|
};
|
|
|
|
// TODO: magnet links do not work
|
|
//set_protocol_handler("magnet", find_file_in_path("transmission-remote -a"));
|
|
|
|
// use emacsclient as external editor.
|
|
editor_shell_command = "emacsclient -c";
|
|
|
|
// view source in external editor.
|
|
view_source_use_external_editor = true;
|
|
|
|
// Enable and configure some page modes
|
|
// See: http://conkeror.org/PageModes
|
|
require("page-modes/xkcd.js");
|
|
page_mode_activate(xkcd_mode);
|
|
xkcd_add_title = true; // insert alt text into the page
|
|
|
|
require("page-modes/reddit.js");
|
|
page_mode_activate(reddit_mode);
|
|
reddit_end_behavior = "page";
|
|
|
|
require("page-modes/duckduckgo.js");
|
|
page_mode_activate(duckduckgo_mode);
|
|
|
|
require("page-modes/youtube.js");
|
|
page_mode_activate(youtube_mode);
|
|
|
|
// use session module
|
|
require("session.js");
|
|
session_auto_save_auto_load = true;
|
|
|
|
// Put history completion along side webjumps
|
|
url_completion_use_history = true;
|
|
url_completion_use_bookmarks = true;
|
|
|
|
// Setup some handy web jumps
|
|
define_webjump("wolframalpha", "http://www.wolframalpha.com/input/?i=%s");
|
|
define_webjump("duckduckgo", "https://duckduckgo.com/?q=%s");
|
|
|
|
// Create some shortcuts to the webjumps above
|
|
webjumps.ddg = webjumps.duckduckgo
|
|
webjumps.wa = webjumps.wolframalpha
|
|
|
|
// START SECTION: thanks to http://conkeror.org/Webjumps
|
|
function chickadee_completer (input, cursor_position, conservative) {
|
|
var completions = [];
|
|
var content = yield send_http_request(
|
|
load_spec({uri: "http://api.call-cc.org/cdoc/ajax/prefix?q="+
|
|
encodeURIComponent(input)}));
|
|
if (content.responseText) {
|
|
var parser = Cc["@mozilla.org/xmlextras/domparser;1"]
|
|
.createInstance(Ci.nsIDOMParser);
|
|
var doc = parser.parseFromString(content.responseText, "text/xml");
|
|
var res = doc.getElementsByTagName("li")
|
|
for (let i = 0, n = res.length; i < n; ++i) {
|
|
completions.push(res[i].textContent);
|
|
}
|
|
}
|
|
yield co_return(prefix_completer($completions = completions)
|
|
(input, cursor_position, conservative));
|
|
}
|
|
|
|
define_webjump("chickadee",
|
|
"http://api.call-cc.org/cdoc?q=%s&query-name=Lookup",
|
|
$alternative = "http://api.call-cc.org/doc/",
|
|
$completer = chickadee_completer);
|
|
|
|
define_webjump("eggref4", "http://wiki.call-cc.org/eggref/4/%s",
|
|
$alternative = "http://wiki.call-cc.org/chicken-projects/egg-index-4.html");
|
|
|
|
define_webjump("srfi", function (i) {
|
|
return "http://srfi.schemers.org/srfi-" + i + "/srfi-" + i + ".html";
|
|
});
|
|
|
|
define_webjump("commandlinefu",
|
|
function(term) {
|
|
return 'http://www.commandlinefu.com/commands/matching/' +
|
|
term.replace(/[^a-zA-Z0-9_\-]/g, '')
|
|
.replace(/[\s\-]+/g, '-') +
|
|
'/' + btoa(term);
|
|
},
|
|
$argument = 'optional',
|
|
$alternative = "http://www.commandlinefu.com/");
|
|
|
|
define_webjump("emacswiki",
|
|
"http://www.google.com/cse?cx=004774160799092323420%3A6-ff2s0o6yi"+
|
|
"&q=%s&sa=Search&siteurl=emacswiki.org%2F",
|
|
$alternative="http://www.emacswiki.org/");
|
|
|
|
define_webjump("savannah", "https://savannah.gnu.org/search/?words=%s&type_of_search=soft");
|
|
|
|
define_webjump("youtube", "http://www.youtube.com/results?search_query=%s&search=Search");
|
|
|
|
|
|
// Do a duckduckgo search if a webjump is not recognized
|
|
read_url_handler_list = [read_url_make_default_webjump_handler("duckduckgo")];
|
|
|
|
// recognize urls a little diffently (allow one worded default webjumps)
|
|
function possibly_valid_url (str) {
|
|
return (/[\.\/:]/.test(str)) &&
|
|
!(/\S\s+\S/.test(str)) &&
|
|
!(/^\s*$/.test(str));
|
|
}
|
|
|
|
// setup tabs (see: http://conkeror.org/Tabs)
|
|
require("new-tabs.js");
|
|
|
|
// Register stylesheet used to theme new-tabs
|
|
register_user_stylesheet("file:///home/collin/.conkeror.d/conkeror.css");
|
|
|
|
// Setup favicon support (in the mode-line)
|
|
require("favicon.js");
|
|
add_hook("mode_line_hook", mode_line_adder(buffer_icon_widget), true);
|
|
read_buffer_show_icons = true;
|
|
|
|
// add loading-count and buffer-count widgets to the mode-line
|
|
add_hook("mode_line_hook", mode_line_adder(loading_count_widget), true);
|
|
add_hook("mode_line_hook", mode_line_adder(buffer_count_widget), true);
|
|
|
|
// remove the clock from the mode-line
|
|
remove_hook("mode_line_hook", mode_line_adder(clock_widget));
|
|
|
|
// force scrolling bars so that incremental search (isearch) works and mousewheel scrolling
|
|
function enable_scrollbars (buffer) {
|
|
buffer.top_frame.scrollbars.visible = true;
|
|
}
|
|
add_hook("create_buffer_late_hook", enable_scrollbars);
|
|
|
|
// Enable spellchecking of text boxes
|
|
session_pref("layout.spellcheckDefault", 2);
|
|
|
|
// Turn on password management in XUL runner
|
|
session_pref("signon.rememberSignons", true);
|
|
session_pref("signon.expireMasterPassword", false);
|
|
session_pref("signon.SignonFileName", "signons.txt");
|
|
Cc["@mozilla.org/login-manager;1"].getService(Ci.nsILoginManager); // init
|
|
|
|
// Some keybindings i like from firefox + pentadactyl, and luakit
|
|
define_key(content_buffer_normal_keymap, "C-f", "buffer-next");
|
|
define_key(content_buffer_normal_keymap, "C-b", "buffer-previous");
|
|
define_key(content_buffer_normal_keymap, "j", "cmd_scrollLineDown");
|
|
define_key(content_buffer_normal_keymap, "k", "cmd_scrollLineUp");
|
|
define_key(content_buffer_normal_keymap, "J", "follow-new-buffer-background");
|
|
define_key(default_global_keymap, "C-x C-b", "switch-to-buffer");
|
|
|
|
// TODO: fix a bug in conkeror-git 120527.1.100.g7994dfa-1 where M-< is bound to scroll-top-left which is either
|
|
// broken or is being depreciated? M-> uses cmd_scrollBottom and internally scroll-top-left uses cmd_scrollTop (then scrolls left).
|
|
// Until this issue is fixed just use cmd_scrollTop for M-<
|
|
define_key(content_buffer_normal_keymap, "M-<", "cmd_scrollTop");
|
|
|
|
// Some code thanks to retroj on #conkeror@irc.freenode.net
|
|
define_browser_object_class(
|
|
"history-url", null,
|
|
function (I, prompt) {
|
|
check_buffer (I.buffer, content_buffer);
|
|
var result = yield I.buffer.window.minibuffer.read_url(
|
|
$prompt = prompt, $use_webjumps = false, $use_history = true, $use_bookmarks = false);
|
|
yield co_return (result);
|
|
},
|
|
$hint = "choose url from history");
|
|
|
|
interactive("find-url-from-history",
|
|
"Find a page from history in the current buffer",
|
|
"find-url",
|
|
$browser_object = browser_object_history_url);
|
|
|
|
interactive("find-url-from-history-new-buffer",
|
|
"Find a page from history in the current buffer",
|
|
"find-url-new-buffer",
|
|
$browser_object = browser_object_history_url);
|
|
|
|
function history_clear () {
|
|
var history = Cc["@mozilla.org/browser/nav-history-service;1"]
|
|
.getService(Ci.nsIBrowserHistory);
|
|
history.removeAllPages();
|
|
}
|
|
interactive("history-clear",
|
|
"Clear the history.",
|
|
history_clear);
|
|
|
|
define_variable("firebug_url",
|
|
"http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js");
|
|
|
|
function firebug (I) {
|
|
var doc = I.buffer.document;
|
|
var script = doc.createElement('script');
|
|
script.setAttribute('type', 'text/javascript');
|
|
script.setAttribute('src', firebug_url);
|
|
script.setAttribute('onload', 'firebug.init();');
|
|
doc.body.appendChild(script);
|
|
}
|
|
interactive("firebug", "open firebug lite", firebug);
|
|
|
|
// use addblock plus extension; see: http://conkeror.org/AdblockPlus?highlight=%28adblock%29
|
|
// AdblockPlus currently not working (Aug 25, 2014)
|
|
require("extensions/adblockplus.js");
|
|
|
|
// Disable whitelist (Causes extensions from unknown/unsigned sites to silently fail if not enabled!)
|
|
//session_pref("xpinstall.whitelist.required", false);
|
|
|
|
// Confirm quiting conkeror
|
|
// See: http://conkeror.org/BreakingChanges
|
|
add_hook("before_quit_hook",
|
|
function () {
|
|
var w = get_recent_conkeror_window();
|
|
var result = (w == null) ||
|
|
"y" == (yield w.minibuffer.read_single_character_option(
|
|
$prompt = "Quit Conkeror? (y/n)",
|
|
$options = ["y", "n"]));
|
|
yield co_return(result);
|
|
});
|
|
|
|
// Proxy code below from: http://conkeror.org/Tips?highlight=%28proxy%29#Proxy_Settings
|
|
// TODO: this proxy stuff still needs to be worked out (tor requires a SOCKS proxy)
|
|
// set the proxy server for this session only
|
|
proxy_server_default = "localhost";
|
|
proxy_port_default = 80;
|
|
|
|
function set_proxy_session (window, server, port) {
|
|
if (server == "N") {
|
|
session_pref('network.proxy.type', 0); //direct connection
|
|
window.minibuffer.message("Direction connection to the internet enabled for this session");
|
|
} else {
|
|
if (server == "") server = proxy_server_default;
|
|
if (port == "") port = proxy_port_default;
|
|
|
|
session_pref('network.proxy.ftp', server);
|
|
session_pref('network.proxy.gopher', server);
|
|
session_pref('network.proxy.http', server);
|
|
session_pref('network.proxy.socks', server);
|
|
session_pref('network.proxy.ssl', server);
|
|
|
|
session_pref('network.proxy.ftp_port', port);
|
|
session_pref('network.proxy.gopher_port', port);
|
|
session_pref('network.proxy.http_port', port);
|
|
session_pref('network.proxy.socks_port', port);
|
|
session_pref('network.proxy.ssl_port', port);
|
|
|
|
session_pref('network.proxy.share_proxy_settings', true);
|
|
session_pref('network.proxy.type', 1);
|
|
|
|
window.minibuffer.message("All protocols using "+server+":"+port+" for this session");
|
|
}
|
|
}
|
|
|
|
interactive("set-proxy-session",
|
|
"set the proxy server for all protocols for this session only",
|
|
function (I) {
|
|
set_proxy_session(
|
|
I.window,
|
|
(yield I.minibuffer.read($prompt = "server ["+proxy_server_default+"] or N: ")),
|
|
(yield I.minibuffer.read($prompt = "port ["+proxy_port_default+"]: ")));
|
|
});
|
|
|
|
|
|
// make hint numbers bigger; see: http://conkeror.org/Tips#Big_Hint_Numbers
|
|
// register_user_stylesheet(
|
|
// "data:text/css," +
|
|
// escape(
|
|
// "@namespace url(\"http://www.w3.org/1999/xhtml\");\n" +
|
|
// "span.__conkeror_hint {\n"+
|
|
// " font-size: 18px !important;\n"+
|
|
// " line-height: 18px !important;\n"+
|
|
// "}"));
|
|
|
|
//TODO: consider something like below to darken pages
|
|
function darken_page (I) {
|
|
var styles='* { background: black !important; color: grey !important; }'+
|
|
':link, :link * { color: #4986dd !important; }'+
|
|
':visited, :visited * { color: #d75047 !important; }';
|
|
var document = I.buffer.document;
|
|
var newSS=document.createElement('link');
|
|
newSS.rel='stylesheet';
|
|
newSS.href='data:text/css,'+escape(styles);
|
|
document.getElementsByTagName("head")[0].appendChild(newSS);
|
|
}
|
|
|
|
interactive("darken-page", "Darken the page in an attempt to save your eyes.",
|
|
darken_page);
|