Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[questions] js for specific sites, keybinds, cookies and colors #997

Open
ghost opened this issue Jun 23, 2022 · 6 comments
Open

[questions] js for specific sites, keybinds, cookies and colors #997

ghost opened this issue Jun 23, 2022 · 6 comments

Comments

@ghost
Copy link

ghost commented Jun 23, 2022

hi! i will ask these question all in one issue because making five seperate issues is not worth it.

i wanted to get insight into 5 things:

  • how can i enable javascript/java for specific sites (permanently)?
  • i followed the docs on how to do keybinds, yet they dont do anything and i dont understand why
  • can i change the colors of the bottom command bar (where it says --INSERT-- for example)? how would i do it?
  • how do i disable cookies and enable them for specific sites?
  • can i set keybinds to open specific websites?

i will provide my full userconf.lua so you can see what i tried, also its to note im not a programmer and dont know a lot about lua. thanks in for the help!

userconf.lua:

local set = require "settings"
set.undoclose.max_saved_tabs = 0
set.webview.user_agent = ""
set.window.home_page = "https://searx.tiekoetter.com"


local dl = require "downloads"
dl.default_dir = os.getenv("HOME") .. "/Downloads"
dl.add_signal("download-location", function (uri, file)
    if not file or file == "" then
        file = (string.match(uri, "/([^/]+)$")
            or string.match(uri, "^%w+://(.+)")
            or string.gsub(uri, "/", "_")
            or "untitled")
    end
    return dl.default_dir .. "/" .. file
end)



--FONTS--
set.webview.default_font_family = "JetBrains Mono"
set.webview.cursive_font_family = "JetBrains Mono"
set.webview.fantasy_font_family = "JetBrains Mono"
set.webview.monospace_font_family = "JetBrains Mono"
set.webview.pictograph_font_family = "JetBrains Mono"
set.webview.sans_serif_font_family = "JetBrains Mono"
set.webview.serif_font_family = "JetBrains Mono"



--ADBLOCK--
require "adblock"
require "adblock_chrome"



--JAVASCRIPT--
local wv = require "webview"
wv.enable_java = false
wv.enable_javascript = false
--for "https://searx.tiekoetter.com" wv.enable_javascript = true
--for "luakit://bookmarks" wv.enable_javascript = true
@ghost ghost changed the title [questions] js for specific sites, keybinds and colors [questions] js for specific sites, keybinds, cookies and colors Jun 23, 2022
@ghost
Copy link
Author

ghost commented Jun 23, 2022

i wanted to add that im very confused with the errors im getting sometimes. it tells me things like how i specified "set" or "webview" are nil values which isnt true because else they wouldnt get sourced. any help is appreciated really im very confused

@MuhammedZakir
Copy link

MuhammedZakir commented Jun 24, 2022

i followed the docs on how to do keybinds, yet they dont do anything and i dont understand why

E.g.

local modes = require 'modes'

modes.add_binds("normal", {
    {
        "<Control-c>", "Copy selected text.", function()
            luakit.selection.clipboard = luakit.selection.primary
        end
    },
    {
        ".", "Stop loading.", function(w) w.view:stop() end
    },
    {
        "<control-m>",
        "Toggle auto_load_images for the current view/tab.",
        function(w)
            w.view.auto_load_images = not w.view.auto_load_images
            w:notify(string.format("w.view.auto_load_images: %s",
                                    w.view.auto_load_images))
        end
    },
})

can i set keybinds to open specific websites?

Why not use quickmarks for this? See https://luakit.github.io/docs/modules/quickmarks.html.

@MuhammedZakir
Copy link

MuhammedZakir commented Jun 24, 2022

Example for settings:

local settings = require 'settings'

local default_search_engine = "duckduckgo"
local search_engines = {
    duckduckgo  = "https://duckduckgo.com/?q=%s",
    google      = "https://google.com/search?q=%s",
    github  = "https://github.com/search?q=%s",

    wikipedia = "https://en.wikipedia.org/wiki/Special:Search?search=%s",
}
local se = search_engines -- for easy typing.
local search_engine_aliases = {
    dd = se.duckduckgo,
    ggi = se.google:gsub("com", "co.in"),

    gh = se.github,
    -- e.g. if terms == "repo owner issues 234", then
    -- url == "https://github.com/repo/owner/issues/234"
    ghr = function (terms)
        return "https://github.com/" .. terms:gsub("%s+", "/")
    end,
}
for k,v in pairs(search_engine_aliases) do
    search_engines[k] = v
end

settings.window.search_engines = search_engines
settings.window.default_search_engine = default_search_engine

@taobert
Copy link
Contributor

taobert commented Jun 24, 2022

  • how can i enable javascript/java for specific sites (permanently)?

The noscript module does this.

  • i followed the docs on how to do keybinds, yet they dont do anything and i dont understand why

There are no keybindings in the userconf.lua you supplied, so this is difficult to troubleshoot.

  • can i change the colors of the bottom command bar (where it says --INSERT-- for example)? how would i do it?

The theme module does this. Currently there is limited capability for dynamic colours (see #524), so depending on how sophisticated a colour scheme you want, you might need to get your hands dirty.

  • how do i disable cookies and enable them for specific sites?

Cookies are dealt with inside webkit (i believe by libsoup). Luakit only defines the filename for the cookie database.
I don't know what functionality libsoup/webkit-gtk may have for finessing cookie capture, but luakit has no code to interface to it.
The cookie database is sqlite3, and you could certainly write a script to munge the file.
You might also be able to set up some slight-of-hand by setting navigation-request event handlers to enable/disable cookie capture based on the url, though this might cause unexpected results if multiple pages are loading (session restore on startup?).

  • can i set keybinds to open specific websites?

Yes.

i wanted to add that im very confused with the errors im getting sometimes. it tells me things like how i specified "set" or "webview" are nil values which isnt true because else they wouldnt get sourced. any help is appreciated really im very confused

Without specific errors paired to specific code, this is difficult to troubleshoot.
I would however hazard a guess that if luajit says that a variable is nil, that it is in fact nil.

What version of Luakit and what system are you running?

@ghost
Copy link
Author

ghost commented Jun 24, 2022

thank you for this, however i know that the noscript module does that. i just dont know how to use it and as i said i dont know where to start because i dont know much lua, sorry for not providing keybinds, when im home ill give an example to what i tried.

so my followup question now is "how do i use the noscript plugin to achieve my goal?"

@taobert
Copy link
Contributor

taobert commented Jun 25, 2022

Look at #937.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants