2022-12-04 23:38:14 +01:00
|
|
|
-----------------------------------------------------------------------
|
|
|
|
-- luakit configuration file, more information at http://luakit.org/ --
|
|
|
|
-----------------------------------------------------------------------
|
|
|
|
|
|
|
|
require "lfs"
|
|
|
|
|
|
|
|
local unique_instance = require "unique_instance"
|
|
|
|
unique_instance.open_links_in_new_window = true
|
|
|
|
|
|
|
|
-- Set the number of web processes to use. A value of 0 means 'no limit'.
|
2024-03-15 07:49:50 +01:00
|
|
|
-- luakit.process_limit = 1
|
2022-12-04 23:38:14 +01:00
|
|
|
|
|
|
|
-- Load library of useful functions for luakit
|
|
|
|
local lousy = require "lousy"
|
|
|
|
|
|
|
|
-- Cookie acceptance policy
|
2024-02-14 07:54:31 +01:00
|
|
|
soup.accept_policy = "no_third_party" -- always, never, no_third_party
|
2022-12-04 23:38:14 +01:00
|
|
|
|
|
|
|
-- Cookie storage location
|
|
|
|
soup.cookies_storage = luakit.data_dir .. "/cookies.db"
|
|
|
|
|
|
|
|
-- Load users theme
|
|
|
|
lousy.theme.init(lousy.util.find_config("theme.lua"))
|
|
|
|
assert(lousy.theme.get(), "failed to load theme")
|
|
|
|
|
|
|
|
-- Load users window class
|
|
|
|
local window = require "window"
|
|
|
|
|
|
|
|
-- Load users webview class
|
|
|
|
local webview = require "webview"
|
|
|
|
|
|
|
|
-- Add luakit://log/ chrome page
|
|
|
|
local log_chrome = require "log_chrome"
|
|
|
|
|
|
|
|
window.add_signal("build", function (w)
|
|
|
|
local widgets, l, r = require "lousy.widget", w.sbar.l, w.sbar.r
|
|
|
|
|
|
|
|
-- Left-aligned status bar widgets
|
|
|
|
l.layout:pack(widgets.uri())
|
|
|
|
l.layout:pack(widgets.hist())
|
|
|
|
l.layout:pack(widgets.progress())
|
2024-02-14 07:54:31 +01:00
|
|
|
l.layout:pack(widgets.zoom())
|
2022-12-04 23:38:14 +01:00
|
|
|
|
|
|
|
-- Right-aligned status bar widgets
|
|
|
|
r.layout:pack(widgets.buf())
|
|
|
|
r.layout:pack(log_chrome.widget())
|
|
|
|
r.layout:pack(widgets.ssl())
|
|
|
|
r.layout:pack(widgets.tabi())
|
|
|
|
r.layout:pack(widgets.scroll())
|
|
|
|
end)
|
|
|
|
|
|
|
|
-- Load luakit binds and modes
|
|
|
|
local modes = require "modes"
|
|
|
|
local binds = require "binds"
|
|
|
|
|
|
|
|
-- Settings (the commented ones do not [yet] work)
|
|
|
|
local settings = require "settings"
|
|
|
|
local settings_chrome = require "settings_chrome"
|
|
|
|
|
|
|
|
settings.window.home_page = "luakit://newtab"
|
2024-02-14 07:54:31 +01:00
|
|
|
-- settings.window.scroll_step = 20
|
2022-12-04 23:38:14 +01:00
|
|
|
settings.window.zoom_step = 0.2
|
2024-12-22 21:08:35 +01:00
|
|
|
settings.webview.zoom_level = 100
|
2022-12-04 23:38:14 +01:00
|
|
|
settings.window.close_with_last_tab = true
|
|
|
|
|
|
|
|
-- search engines
|
2023-08-19 10:47:45 +02:00
|
|
|
settings.window.search_engines.ddg = "https://duckduckgo.com/?q=%s"
|
2024-02-14 07:54:31 +01:00
|
|
|
settings.window.search_engines.g = "https://google.com/?q=%s"
|
|
|
|
settings.window.search_engines.mg = "https://metager.org/?q=%s"
|
|
|
|
settings.window.search_engines.gh = "https://github.com/search?q=%s"
|
|
|
|
settings.window.search_engines.default = settings.window.search_engines.ddg
|
2022-12-04 23:38:14 +01:00
|
|
|
|
|
|
|
----------------------------------
|
|
|
|
-- Optional user script loading --
|
|
|
|
----------------------------------
|
|
|
|
|
|
|
|
-- Add adblock
|
2024-12-22 21:08:35 +01:00
|
|
|
local adblock = require "adblock"
|
|
|
|
local adblock_chrome = require "adblock_chrome"
|
2022-12-04 23:38:14 +01:00
|
|
|
|
|
|
|
-- Enable Developer Tools
|
2024-12-22 21:08:35 +01:00
|
|
|
local webinspector = require "webinspector"
|
2022-12-04 23:38:14 +01:00
|
|
|
|
|
|
|
-- Add uzbl-like form filling
|
|
|
|
-- local formfiller = require "formfiller"
|
|
|
|
-- formfiller.extend({
|
|
|
|
-- pass = function(s) return io.popen("pass " .. s):read() end
|
|
|
|
-- })
|
|
|
|
|
|
|
|
-- Add proxy support & manager
|
2024-02-14 07:54:31 +01:00
|
|
|
-- local proxy = require "proxy"
|
2022-12-04 23:38:14 +01:00
|
|
|
|
|
|
|
-- Add quickmarks support & manager
|
|
|
|
-- local quickmarks = require "quickmarks"
|
|
|
|
|
|
|
|
-- Add session saving/loading support
|
|
|
|
-- local session = require "session"
|
|
|
|
|
|
|
|
-- Enable Gopher protocol support
|
|
|
|
local gopher = require "gopher"
|
|
|
|
|
|
|
|
-- Delete website data
|
2024-02-14 07:54:31 +01:00
|
|
|
-- local clear_data = require "clear_data"
|
2022-12-04 23:38:14 +01:00
|
|
|
|
|
|
|
-- Add command to list closed tabs & bind to open closed tabs
|
|
|
|
local undoclose = require "undoclose"
|
|
|
|
|
|
|
|
-- Add command to list tab history items
|
2024-12-22 21:08:35 +01:00
|
|
|
local tabhistory = require "tabhistory"
|
2022-12-04 23:38:14 +01:00
|
|
|
|
|
|
|
-- Add greasemonkey-like javascript userscript support
|
2024-12-22 21:08:35 +01:00
|
|
|
local userscripts = require "userscripts"
|
2022-12-04 23:38:14 +01:00
|
|
|
|
|
|
|
-- Add bookmarks support
|
2024-12-22 21:08:35 +01:00
|
|
|
local bookmarks = require "bookmarks"
|
|
|
|
local bookmarks_chrome = require "bookmarks_chrome"
|
2022-12-04 23:38:14 +01:00
|
|
|
|
|
|
|
-- Add download support
|
|
|
|
local downloads = require "downloads"
|
|
|
|
local downloads_chrome = require "downloads_chrome"
|
|
|
|
downloads.default_dir = os.getenv("HOME") .. "/Downloads"
|
|
|
|
|
|
|
|
-- Add automatic PDF downloading and opening
|
2024-02-14 07:54:31 +01:00
|
|
|
local viewpdf = require "viewpdf"
|
2022-12-04 23:38:14 +01:00
|
|
|
|
|
|
|
-- Add vimperator-like link hinting & following
|
|
|
|
local follow = require "follow"
|
|
|
|
|
|
|
|
-- Add command history
|
|
|
|
local cmdhist = require "cmdhist"
|
|
|
|
|
|
|
|
-- Add search mode & binds
|
|
|
|
local search = require "search"
|
|
|
|
|
|
|
|
-- Add ordering of new tabs
|
2024-02-14 07:54:31 +01:00
|
|
|
-- local taborder = require "taborder"
|
2022-12-04 23:38:14 +01:00
|
|
|
|
|
|
|
-- Save web history
|
|
|
|
local history = require "history"
|
|
|
|
local history_chrome = require "history_chrome"
|
|
|
|
|
|
|
|
-- :help pages
|
|
|
|
local help_chrome = require "help_chrome"
|
|
|
|
local binds_chrome = require "binds_chrome"
|
|
|
|
|
|
|
|
-- Add command completion
|
|
|
|
local completion = require "completion"
|
|
|
|
|
|
|
|
-- Press Control-E while in insert mode to edit the contents of the currently
|
|
|
|
-- focused <textarea> or <input> element, using `xdg-open`
|
2022-12-13 23:16:23 +01:00
|
|
|
-- local open_editor = require "open_editor"
|
|
|
|
-- local editor = require "editor"
|
|
|
|
-- editor.editor_cmd = "hterm vim {file}"
|
2022-12-04 23:38:14 +01:00
|
|
|
|
|
|
|
-- NoScript plugin, toggle scripts and or plugins on a per-domain basis.
|
|
|
|
-- `,ts` to toggle scripts, `,tp` to toggle plugins, `,tr` to reset.
|
|
|
|
-- If you use this module, don't use any site-specific `enable_scripts` or
|
|
|
|
-- `enable_plugins` settings, as these will conflict.
|
2024-02-14 07:54:31 +01:00
|
|
|
-- require "noscript"
|
2022-12-04 23:38:14 +01:00
|
|
|
|
|
|
|
local follow_selected = require "follow_selected"
|
|
|
|
local go_input = require "go_input"
|
|
|
|
local go_next_prev = require "go_next_prev"
|
|
|
|
local go_up = require "go_up"
|
|
|
|
|
|
|
|
-- Filter Referer HTTP header if page domain does not match Referer domain
|
2022-12-13 23:16:23 +01:00
|
|
|
-- require_web_module("referer_control_wm")
|
2022-12-04 23:38:14 +01:00
|
|
|
|
|
|
|
local error_page = require "error_page"
|
|
|
|
|
|
|
|
-- Add userstyles loader
|
|
|
|
local styles = require "styles"
|
|
|
|
follow.stylesheet = follow.stylesheet .. [===[
|
|
|
|
#luakit_select_overlay .hint_label {
|
2024-02-14 07:54:31 +01:00
|
|
|
background-color: #f8f8f8 !important;
|
|
|
|
border: 1px solid #f00 !important;
|
|
|
|
padding: 1px !important;
|
|
|
|
color: #181818 !important;
|
|
|
|
font-size: 16px !important;
|
|
|
|
opacity: 0.7 !important;
|
2022-12-04 23:38:14 +01:00
|
|
|
}
|
|
|
|
]===]
|
|
|
|
|
|
|
|
-- Hide scrollbars on all pages
|
2024-02-14 07:54:31 +01:00
|
|
|
-- local hide_scrollbars = require "hide_scrollbars"
|
2022-12-04 23:38:14 +01:00
|
|
|
|
|
|
|
-- local vertical_tabs = require "vertical_tabs"
|
|
|
|
|
|
|
|
-- Add a stylesheet when showing images
|
2024-02-14 07:54:31 +01:00
|
|
|
-- local image_css = require "image_css"
|
2022-12-04 23:38:14 +01:00
|
|
|
|
|
|
|
-- Add a new tab page
|
|
|
|
local newtab_chrome = require "newtab_chrome"
|
|
|
|
newtab_chrome.new_tab_src = [==[
|
|
|
|
<html>
|
|
|
|
<head><title>New Tab</title></head>
|
|
|
|
<body bgcolor=black></body>
|
|
|
|
</html>
|
|
|
|
]==]
|
|
|
|
|
|
|
|
-- Add tab favicons mod
|
2024-02-14 07:54:31 +01:00
|
|
|
local tab_favicons = require "tab_favicons"
|
2022-12-04 23:38:14 +01:00
|
|
|
-- local tab = require("lousy.widget.tab")
|
|
|
|
-- tab.label_format = ""
|
|
|
|
|
2023-08-28 08:12:53 +02:00
|
|
|
-- local tablist = require("lousy.widget.tablist")
|
|
|
|
-- tablist.min_width = 100
|
2022-12-04 23:38:14 +01:00
|
|
|
|
|
|
|
-- Add :view-source command
|
2024-02-14 07:54:31 +01:00
|
|
|
-- local view_source = require "view_source"
|
2022-12-04 23:38:14 +01:00
|
|
|
|
|
|
|
-- Use "asdfqwerzxcv" for generating labels
|
|
|
|
local select = require "select"
|
|
|
|
select.label_maker = function (s)
|
|
|
|
return s.trim(s.sort(s.reverse(s.charset("qwertzuiopasfghjklyxcvbnm"))))
|
|
|
|
end
|
|
|
|
follow.pattern_maker = follow.pattern_styles.match_label
|
|
|
|
|
2023-08-28 08:12:53 +02:00
|
|
|
|
2023-11-01 18:08:32 +01:00
|
|
|
-- -- social media enhancer
|
|
|
|
-- local webview = require "webview"
|
|
|
|
-- webview.add_signal('init', function (view)
|
|
|
|
-- view:add_signal('navigation-request', function(v, uri)
|
|
|
|
-- if v.uri:match('https://www.reddit.com') then
|
|
|
|
-- v.uri = v.uri:gsub('%www.reddit.com', 'old.reddit.com')
|
|
|
|
-- return true
|
|
|
|
-- end
|
|
|
|
-- if v.uri:match('https://new.reddit.com') then
|
|
|
|
-- v.uri = v.uri:gsub('%new.reddit.com', 'old.reddit.com')
|
|
|
|
-- return true
|
|
|
|
-- end
|
|
|
|
-- -- if v.uri:match('https://old.reddit.com') then
|
|
|
|
-- -- v.uri = v.uri:gsub('%old.reddit.com', 'libreddit.kylrth.com')
|
|
|
|
-- -- return true
|
|
|
|
-- -- end
|
|
|
|
-- -- if v.uri:match('https://old.reddit.com') then
|
|
|
|
-- -- v.uri = v.uri:gsub('%old.reddit.com', 'libreddit.kylrth.com')
|
|
|
|
-- -- return true
|
|
|
|
-- -- end
|
|
|
|
-- if v.uri:match('https://www.twitter.com') then
|
|
|
|
-- v.uri = v.uri:gsub('%www.twitter.com', 'nitter.net')
|
|
|
|
-- return true
|
|
|
|
-- end
|
|
|
|
-- if v.uri:match('https://twitter.com') then
|
|
|
|
-- v.uri = v.uri:gsub('%twitter.com', 'nitter.net')
|
|
|
|
-- return true
|
|
|
|
-- end
|
|
|
|
-- if v.uri:match('https://www.youtube.com') then
|
|
|
|
-- v.uri = v.uri:gsub('%www.youtube.com', 'tube.cadence.moe')
|
|
|
|
-- return true
|
|
|
|
-- end
|
|
|
|
-- if v.uri:match('https://youtube.com') then
|
|
|
|
-- v.uri = v.uri:gsub('%youtube.com', 'tube.cadence.moe')
|
|
|
|
-- return true
|
|
|
|
-- end
|
|
|
|
-- if v.uri:match('https://youtu.be') then
|
|
|
|
-- v.uri = v.uri:gsub('%youtu.be/', 'tube.cadence.moe/watch?v=')
|
|
|
|
-- return true
|
|
|
|
-- end
|
|
|
|
-- end)
|
|
|
|
-- end)
|
2022-12-04 23:38:14 +01:00
|
|
|
|
|
|
|
-- social media blocker
|
2024-02-14 07:54:31 +01:00
|
|
|
-- local webview = require "webview"
|
|
|
|
-- webview.add_signal('init', function (view)
|
|
|
|
-- view:add_signal('navigation-request', function(v, uri)
|
|
|
|
-- local blocklist_pattern = {
|
|
|
|
-- "facebook.com",
|
|
|
|
-- ".fb.com",
|
|
|
|
-- ".fbcdn.com",
|
|
|
|
-- ".fbsbx.com",
|
|
|
|
-- ".fbcdn.net",
|
|
|
|
-- ".tfbnw.net",
|
|
|
|
-- "whatsapp.com",
|
|
|
|
-- "online-metrix.net",
|
|
|
|
-- ".fb.me",
|
|
|
|
-- "facebook-web-clients.appspot.com",
|
|
|
|
-- "fbcdn-profile-a.akamaihd.net"
|
|
|
|
-- }
|
|
|
|
-- for key,value in ipairs(blocklist_pattern)
|
|
|
|
-- do
|
|
|
|
-- if v.uri:match(value) then
|
|
|
|
-- print("Navigation request to " .. v.uri .. " blocked.")
|
|
|
|
-- return false
|
|
|
|
-- end
|
|
|
|
-- end
|
|
|
|
-- end)
|
|
|
|
-- end)
|
2022-12-04 23:38:14 +01:00
|
|
|
|
|
|
|
-----------------------------
|
|
|
|
-- End user script loading --
|
|
|
|
-----------------------------
|
|
|
|
|
|
|
|
-- Open window
|
|
|
|
window.new(uris)
|
|
|
|
|
|
|
|
-- vim: et:sw=4:ts=8:sts=4:tw=80
|
2023-09-18 12:24:42 +02:00
|
|
|
|