-
Notifications
You must be signed in to change notification settings - Fork 0
/
conkerorrc
550 lines (428 loc) · 21.6 KB
/
conkerorrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
/* -*- javascript -*-
http://emacs-fu.blogspot.com/2010/12/conkeror-web-browsing-emacs-way.html
http://conkeror.org/ExampleConfigs
retroj's booklist:
http://www.goodreads.com/user/show/6789591-nibbledtodeathbycats
When something steals focus in conkeror, and C-x C-b/k wont work:
conkeror -f unfocus
To manage history:
https://github.com/joseph-gay/conkeror-histmark
*/
// GENERAL CONFIGURATIONS
//------------------------
// Make font bigger of link hints
register_user_stylesheet(
"data:text/css," +
escape(
"@namespace url(\"http://www.w3.org/1999/xhtml\");\n" +
"span.__conkeror_hint {\n"+
" font-size: 16px !important;\n"+
" line-height: 16px !important;\n"+
"}"));
// stop github from stealing my keys
//require('github');
require("block-content-focus-change.js");
//TEST!:
//require('daemon');
//daemon_mode(1);
// //allow installing extensions (such as adblock):
session_pref("xpinstall.whitelist.required", false);
// Or twitter thinks my copmuter is a mobile phone.
session_pref("general.useragent.compatMode.firefox", true)
//set_protocol_handler("magnet", null);
set_protocol_handler("magnet", make_file("~/usr/bin/magnet.sh"));
//allow for 'contrib' stuff (DONT KNOW WHAT THIS ONE DOES?)
load_paths.unshift("chrome://conkeror-contrib/content/");
homepage = "about:blank";
// For TOR onion network:
// session_pref("network.proxy.socks", "localhost");
// session_pref("network.proxy.socks_port", 9050);
// session_pref("network.proxy.type", 1);
// session_pref("network.proxy.socks_remote_dns", true);
// theme_load_paths.push("~/usr/src/conkeror/style");
// theme_load("mono");
//TEST!
interactive("find-url-from-history",
"Open a URL in the current buffer",
function (I) {
var target = I.browse_target("find-url");
open_in_browser(I.buffer, target,
(yield I.minibuffer.read_url($prompt =
browse_target_prompt(target), $use_webjumps = false, $use_history =
true, $use_bookmarks = false)));
});
// https://gist.github.com/jsrjenkins/8af7ea18ae66b29abb4e827011726a4a
interactive(
"ublock", "Open uBlock dashboard in a new buffer",
function (I) {
var ublock_branch;
if ("@ublock0/content-policy;1" in Cc) {
ublock_branch = "ublock0";
} else if ("@ublock/content-policy;1" in Cc) {
ublock_branch = "ublock";
} else {
throw interactive_error("uBlock not found");
}
load_url_in_new_buffer("chrome://"+ublock_branch+"/content/dashboard.html");
}
);
const cookie_culler_chrome = "chrome://cookieculler/content/CookieCuller.xul";
interactive("cookie-culler", "Open the CookieCuller settings in a new buffer.",
"find-url-new-buffer",
$browser_object = cookie_culler_chrome);
//remember state upon close, and restore if wanted.
//Note: must close using C-x C-c, not by using window manager
require("session.js");
session_auto_save_auto_load = true; // true, false, or "propt"
//delay-content BEGIN ====================================================
/*
This script is a hack that provides delayed loading for content buffers.
The initial url of a buffer will not be loaded until that buffer is
switched to. Precaution is taken that the buffer's display_uri_string
returns the delayed url, not about:blank, so things like tabs and sessions
will still work properly.
*/
function content_delay (spec) {
this.delayed_load = spec;
}
function content_delay_init (b) {
if (b != b.window.buffers.current &&
b instanceof content_buffer &&
b.opener instanceof session_token)
{
b.load = content_delay;
b.__defineGetter__("display_uri_string",
function () {
if (this.delayed_load) {
if (this.delayed_load instanceof load_spec)
return load_spec_uri_string(this.delayed_load);
return this.delayed_load;
}
if (this._display_uri)
return this._display_uri;
if (this.current_uri)
return this.current_uri.spec;
return "";
});
}
}
function content_delay_do_initial_load (b) {
if (b.hasOwnProperty("load")) {
delete b.load;
if (b.hasOwnProperty("delayed_load")) {
b.load(b.delayed_load);
delete b.delayed_load;
}
}
}
add_hook("create_buffer_early_hook", content_delay_init);
add_hook("select_buffer_hook", content_delay_do_initial_load);
//delay-content END ====================================================
// http://conkeror.org/NoScript
//require("noscript");
// prevent conkeror from loosing session memory when opening a-new when following a link.
session_auto_save_auto_load_fn = session_auto_save_load_window_current;
// we'd like to see the # of buffers being loaded
add_hook("mode_line_hook", mode_line_adder(loading_count_widget), true);
// but really we'd also like to know how many buffers are present and which is the current
add_hook("mode_line_hook", mode_line_adder(buffer_count_widget), true);
//Open Middle-Clicked Links in New Buffers
require("clicks-in-new-buffer.js");
// Now buffers open in background.
clicks_in_new_buffer_target = OPEN_NEW_BUFFER_BACKGROUND;
//Should work, check Debian-Bug #608758 --> conkeror issue335
//print.postscript.enabled = true;
user_pref("print.postscript.paper_size", "A4");
//no clock in the mode-line.
remove_hook("mode_line_hook", mode_line_adder(clock_widget));
// 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;
// default directory for downloads and shell commands.
// cwd = get_home_directory();
// cwd.append("downloads");
function update_save_path (info) {
cwd = info.target_file.parent;
}
add_hook("download_added_hook", update_save_path);
// // stop sites from stealing my keys
// require("key-kill");
// key_kill_mode.test.push(build_url_regexp($domain = "github"));
// key_kill_mode.test.push(/\/\/.*slashdot\.org\//);
// key_kill_mode.test.push(/\/\/.*smbc-comics\.com\//);
// key_kill_mode.test.push(/\/\/.*tradera\.com\//); // nope.
// key_kill_mode.test.push(/\/\/.*lomography\.com\//);
// key_kill_mode.test.push(/\/\/.*kickstarter\.com\//);
// key_kill_mode.test.push(/\/\/.*dreamincode\.net\//);
// key_kill_mode.test.push(/\/\/.*ncbi\.nlm\.nih\.gov\//);
// view source in your editor. (M-x view-source)
view_source_use_external_editor = true;
// use emacs as external editor.
editor_shell_command = "emacsclient -c -a \"\"";
// let xkcd-mode put the funny alt text into the page.
xkcd_add_title = true;
// auto completion in the minibuffer
minibuffer_auto_complete_default = true;
url_completion_use_history = true; // should work since bf05c87405
url_completion_use_bookmarks = true;
//number of days to save history:
session_pref('browser.history_expire_days', 500);
// KEYBINDINGS
//-------------
define_key(content_buffer_normal_keymap, "d", "follow-new-buffer-background");
//open new buffer of new url in background. No more C-x C-f <url> C-x b
interactive("find-url-new-background-buffer",
"Open a URL in a new buffer in the background",
alternates(follow_new_buffer_background, follow_new_window),
$browser_object = browser_object_url,
$prompt = "Find url");
define_key(content_buffer_normal_keymap, "w", "find-url-new-background-buffer");
//scroll like in elinks, with ins/del
define_key(content_buffer_normal_keymap, "delete", "cmd_scrollLineDown");
define_key(content_buffer_normal_keymap, "insert", "cmd_scrollLineUp");
// go to top/end of page like Emacs
define_key(content_buffer_normal_keymap, "C-x [", "scroll-top-left");
define_key(content_buffer_normal_keymap, "C-x ]", "cmd_scrollBottom");
key_bindings_ignore_capslock = true;
// Make sure I don't close by accident
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);
});
//C-x k wont work, use C-x C-c:
can_kill_last_buffer = false;
//http://conkeror.org/Focus, or else flash steals window focus.
function focusblock (buffer) {
var s = Components.utils.Sandbox(buffer.top_frame);
s.document = buffer.document.wrappedJSObject;
Components.utils.evalInSandbox(
"(function () {\
function nothing () {}\
if (! document.forms)\
return;\
for (var i = 0, nforms = document.forms.length; i < nforms; i++) {\
for (var j = 0, nels = document.forms[i].elements.length; j < nels; j++)\
document.forms[i].elements[j].focus = nothing;\
}\
})();",
s);
}
add_hook('content_buffer_progress_change_hook', focusblock);
//Use key 1,2,3,4,5,6,7,8,9,0 as shortcut for buffer 1-10.
function define_switch_buffer_key (key, buf_num) {
define_key(default_global_keymap, key,
function (I) {
switch_to_buffer(I.window,
I.window.buffers.get_buffer(buf_num));
});
}
for (let i = 0; i < 10; ++i) {
define_switch_buffer_key(String((i+1)%10), i);
}
// TEST MPV
//-----------
//http://jaderholm.com/paste/mpv.js.html
var mpv_default_command = "mpv";
var mpv_last_command = mpv_last_command || mpv_default_command;
interactive("mpv",
"Play url in mpv",
function (I) {
var cwd = I.local.cwd;
var element = yield read_browser_object(I);
var spec = load_spec(element);
var uri = load_spec_uri_string(spec);
var panel = create_info_panel(
I.window,
"download-panel",
[["downloading",
element_get_operation_label(element, "Running on", "URI"),
load_spec_uri_string(spec)],
["mime-type", "Mime type:", load_spec_mime_type(spec)]]);
try {
var cmd = yield I.minibuffer.read_shell_command(
$cwd = cwd,
$initial_value = mpv_last_command);
mpv_last_command = cmd;
} finally {
panel.destroy();
}
shell_command_with_argument_blind(cmd+" {}", uri, $cwd = cwd);
},
$browser_object = browser_object_links);
define_key(content_buffer_normal_keymap, "a", "mpv");
// WEBJUMPS / BOOKMARKS
//----------------------
// Prompt and fast English-language TV shows.
// https://eztv.it/
// Simplistic, low-frills meta-search.
define_webjump("isohunt", "https://isohunt.com/torrents/?ihq=%s");
// KickassTorrents, an aptly named site. Voluminous metadata and effective presentation.
define_webjump("kat", "https://kat.ph/usearch/%s");
// A good alternative to btjunkie. =)
define_webjump("torrentz", "https://torrentz.eu/search?f=%s");
// some bookmarks
define_webjump("conk", "http://conkeror.org");
define_webjump("efu", "http://emacs-fu.blogspot.com");
//define_webjump("ew", "http://emacswiki.org");
define_webjump("ew", "http://www.google.com/search?q=%s&as_sitesearch=http://emacswiki.org",
$alternative="http://emacswiki.org");
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("so", "http://stackoverflow.com/search?q=%s");
define_webjump("youtube", "http://www.youtube.com/results?search_query=%s&aq=f", $alternative="http://www.youtube.com/");
define_webjump("yt", "http://www.youtube.com/results?search_query=%s&aq=f", $alternative="http://www.youtube.com/");
define_webjump("imdb", "http://www.imdb.com/find?q=%s&s=all", $alternative="http://www.imdb.com/");
// better than googel translate, for supported languages: https://www.deepl.com/translator
define_webjump("trans", "http://translate.google.com/translate_t#auto|en|%s");
define_webjump("alpha", "http://www36.wolframalpha.com/input/?i=%s");
define_webjump("allmusic", "http://www.allmusic.com/search/artist/%s");
define_webjump("abebooks", "http://www.abebooks.com/servlet/SearchResults?kn=%s");
define_webjump("antikvariat", "https://www.antikvariat.net/sv/front?currency=SEK");
define_webjump("ascii", "http://www.asciisector.net/forum");
define_webjump("arch", "https://wiki.archlinux.org/index.php?title=Special%3ASearch&search=%s",
$alternative="http://www.archlinux.org/");
define_webjump("aur", "https://aur.archlinux.org/packages?O=0&K=%s", $alternative="https://aur.archlinux.org/");
define_webjump("bbc", "http://www.bbc.co.uk/news/world/");
define_webjump("biblioteket", "http://biblioteksportalen.lund.se/web/arena/");
define_webjump("c++", "http://www.cplusplus.com/search.do?q=%s");
define_webjump("clock", "http://dev.thep.lu.se/clocks/");
define_webjump("debian", "http://forums.debian.net/");
define_webjump("debpkg", "http://packages.debian.org/%s");
define_webjump("dividend", "http://www.dividend.com/");
// https://help.duckduckgo.com/duckduckgo-help-pages/features/non-javascript/
define_webjump("duck", "https://html.duckduckgo.com/html?q=%s", $alternative="https://duckduckgo.com/html");
define_webjump("Duck", "https://duckduckgo.com/?q=%s", $alternative="https://duckduckgo.com/");
define_webjump("ebay", "http://www.ebay.com/sch/i.html?_nkw=%s",
$alternative="http://my.ebay.co.uk");
define_webjump("news", "https://ground.news")
define_webjump("tube", "https://tube.quinzel.tech")
define_webjump("ebay_gixen", "http://www.gixen.com/index.php");
define_webjump("G", "https://encrypted.google.com/search?hl=en&source=hp&q=%s");
define_webjump("git", "https://github.com/impaktor");
define_opensearch_webjump("g", "google.xml") // om man har andra alias som börjar på "g"
define_webjump("outlook", "https://outlook.office.com/owa/");
define_webjump("openstreetmap", "https://www.openstreetmap.org/search?query=%s", $alternative="https://www.openstreetmap.org");
define_webjump("eniro", "http://gulasidorna.eniro.se/hitta:%s");
define_webjump("karlf", "http://home.thep.lu.se/~karlf");
define_webjump("kart", "http://kart.finn.no/");
define_webjump("kalender", "http://www.norskkalender.no/");
define_webjump("mathworld", "http://mathworld.wolfram.com/search/?query=%s&x=0&y=0");
define_webjump("archive", "https://archive.vn/");
define_webjump("metalarchives", "http://www.metal-archives.com/search?searchString=%s&type=band_name");
define_webjump("minecraftwiki", "http://www.minecraftwiki.net/wiki/Minecraft_Wiki");
define_webjump("norsk", "https://naob.no/ordbok/%s", $alternative="https://naob.no/ordbok/");
define_webjump("pioneerwiki", "https://wiki.pioneerspacesim.net");
define_webjump("pioneerwikiadminspecial", "https://pioneerwiki.com/wiki/Special:SpecialPages");
define_webjump("pioneerwikiadminversion", "https://pioneerwiki.com/wiki/Special:Version");
define_webjump("pioneertravis", "https://travis-ci.org/pioneerspacesim/pioneer");
define_webjump("pioneerforum", "http://forum.pioneerspacesim.net/");
define_webjump("pioneer", "http://pioneerspacesim.net/");
define_webjump("pioneerapi", "http://codedoc.pioneerspacesim.net/");
define_webjump("pioneergit", "https://github.com/pioneerspacesim/pioneer/issues/%s",
$alternative="https://github.com/pioneerspacesim/pioneer");
define_webjump("pioneertrans", "https://www.transifex.com/projects/p/pioneer/");
define_webjump("pioneertweet", "https://twitter.com/pioneerspacesim/");
define_webjump("pioneerssc", "https://spacesimcentral.com/community/pioneer/");
define_webjump("ssc", "https://spacesimcentral.com/community/pioneer/");
define_webjump("smbc", "http://www.smbc-comics.com/");
define_webjump("smhi", "http://www.smhi.se/vadret/vadret-i-sverige/land/fiveDaysForecast.do?geonameid=2693678");
define_webjump("seb", "http://www.seb.se");
define_webjump("sms", "http://receive-sms-online.com");
define_webjump("thinkwiki", "http://www.thinkwiki.org/wiki/Category:Models");
define_webjump("thep", "http://cbbp.thep.lu.se/publications/publications.html");
//define_webjump("tradera", "http://gamla.tradera.com/finding.mvc/itemlisting?header=true&search=%s", $alternative="http://gamla.tradera.com");
define_webjump("tv", "http://www.tv.nu");
define_webjump("urban", "http://www.urbandictionary.com/define.php?term=%s");
define_webjump("valuta", "http://www.valuta.se");
define_webjump("wifi", "http://192.168.1.254/login.cgi");
define_webjump("rateyourmusic", "http://rateyourmusic.com/search?searchtype=a&searchterm=%s", $alternative="http://rateyourmusic.com/");
define_webjump("rottentomatoes","http://www.rottentomatoes.com/search/full_search.php?search=%s");
define_webjump("xkcd", "http://www.xkcd.com/");
define_webjump("scala", "http://www.scala-lang.org/api/current");
define_webjump("scheme", "http://www.schemers.org/Documents/Standards/R5RS/HTML/");
define_webjump("seekingalpha", "http://seekingalpha.com/symbol/%s");
define_webjump("qwant", "https://www.qwant.com/?q=%s", $alternative="https://www.qwant.com/");
define_webjump("hackernews", "http://www.google.com/search?q=site:news.ycombinator.com+%s",
$alternative = "http://news.ycombinator.com/");
define_webjump("recordheaven", "http://www.recordheaven.net/");
define_webjump("bloodharvest", "http://bloodharvest.se/catalog/");
define_webjump("sds", "http://www.sydsvenskan.se/");
define_webjump("svd", "http://svd.se/");
define_webjump("dn", "http://www.dn.se/");
define_webjump("di", "http://www.di.se/");
define_webjump("xxl", "https://xxl.no/search?q=%s");
define_webjump("unvisit", "http://unvis.it/%s", $alternative="http://unvis.it/");
// open source search page: https://stract.com/
define_webjump("s", "https://www.startpage.com/do/search",
$post_data = [["query", "%s"], ["cat", "web"],
["cmd", "process_search"], ["language", "english"],
["engine0", "v1all"], ["abp", "-1"]],
$alternative="https://www.startpage.com");
//use free dictionary instead:
define_webjump("dictionary","http://www.thefreedictionary.com/%s");
define_webjump("synonym", "http://www.thefreedictionary.com/%s#Thesaurus");
define_webjump("paste", "http://paste.pocoo.org/");
define_webjump("pirate", "https://thepiratebay.se/search/%s");
define_webjump("python", "http://docs.python.org/search.html?q=%s");
define_webjump("eol", "http://eol.org/search?q=%s&ie=UTF-8&search_type=text");
define_webjump("weather", "http://www.wunderground.com/cgi-bin/findweather/getForecast?query=%s");
define_webjump("weatherspark","http://weatherspark.com/#!graphs;q=%s",
$alternative="http://weatherspark.com");
//is webpage down for just me?
define_webjump("down?", function (url) {
if (url) {
return "http://downforeveryoneorjustme.com/" + url;
} else {
return "javascript:window.location.href='http://downforeveryoneorjustme.com/'+window.location.href;";
}
}, $argument = "optional");
//FUNCTIONS
//---------
//Do M-: and form_history_clear() to clear / reset formfill history, like usernames etc.
function form_history_clear () {
var file = Cc["@mozilla.org/file/directory_service;1"]
.getService(Ci.nsIProperties)
.get("ProfD", Ci.nsIFile);
file.append("formhistory.sqlite");
var storage = Cc["@mozilla.org/storage/service;1"]
.getService(Ci.mozIStorageService);
var db = storage.openDatabase(file);
if (! db.tableExists("moz_formhistory"))
return;
var statement = db.createStatement("delete FROM moz_formhistory");
statement.execute();
}
// http://retroj.net/git/conkerorrc/history.js
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);
// END
// ---
//does this print, when starting conkeror from terminal?
dumpln("Configuration file read to end of line. All is well.");
// // http://conkeror.org/ExternalPrograms?#shell_command_blind
// // http://conkeror.org/WritingBrowserObjectCommands
// // http://conkeror.org/BrowserObjects?highlight=%28browser%29%7C%28object%29
// interactive("shell-command-mplayer",
// "Play url in mplayer",
// function (I) {
// var cwd = I.local.cwd;
// var element = yield read_browser_object(I);
// var spec = load_spec(element);
// var uri = load_spec_uri_string(spec);
// var cmd = "mplayer -fs $(youtube-dl -g \"$url\")"; \\ it would be better to use script, b/c of escaping
// shell_command_with_argument_blind(cmd, uri, $cwd = cwd);
// },
// $browser_object = browser_object_url);
// define_key(content_buffer_normal_keymap, "C-c x", "playVideo", $browser_object = browser_object_links);