restore adblock (rather messy)
This commit is contained in:
parent
b7956d70bb
commit
da435b0667
@ -135,7 +135,7 @@ progress, trough {
|
|||||||
container (Gtk.Box {
|
container (Gtk.Box {
|
||||||
:orientation Gtk.Orientation.VERTICAL
|
:orientation Gtk.Orientation.VERTICAL
|
||||||
})
|
})
|
||||||
viewplex (Viewplex.new)
|
viewplex (Viewplex.new {:content-filter-store content-filter-store})
|
||||||
navbar (Navbar.new viewplex)
|
navbar (Navbar.new viewplex)
|
||||||
progress-bar (Gtk.ProgressBar {
|
progress-bar (Gtk.ProgressBar {
|
||||||
:orientation Gtk.Orientation.HORIZONTAL
|
:orientation Gtk.Orientation.HORIZONTAL
|
||||||
@ -154,11 +154,12 @@ progress, trough {
|
|||||||
|
|
||||||
(if (. arg 1)
|
(if (. arg 1)
|
||||||
(each [_ url (ipairs arg)]
|
(each [_ url (ipairs arg)]
|
||||||
(let [v (Webview.new)]
|
(let [v (Webview.new {:content-filter-store content-filter-store} )]
|
||||||
(v:visit url)
|
(v:visit url)
|
||||||
(viewplex:add-view v)))
|
(viewplex:add-view v)))
|
||||||
(viewplex:add-view
|
(viewplex:add-view
|
||||||
(doto (Webview.new) (: :visit "about:blank"))))
|
(doto (Webview.new {:content-filter-store content-filter-store})
|
||||||
|
(: :visit "about:blank"))))
|
||||||
|
|
||||||
(window:add container)
|
(window:add container)
|
||||||
(window:show_all))
|
(window:show_all))
|
||||||
|
@ -59,7 +59,8 @@
|
|||||||
:height 200
|
:height 200
|
||||||
:on_clicked (fn []
|
:on_clicked (fn []
|
||||||
(self:add-view
|
(self:add-view
|
||||||
(doto (Webview.new)
|
(doto (Webview.new
|
||||||
|
{:content-filter-store self.content-filter-store})
|
||||||
(: :visit "about:blank"))))
|
(: :visit "about:blank"))))
|
||||||
})
|
})
|
||||||
false false 5)
|
false false 5)
|
||||||
@ -71,7 +72,7 @@
|
|||||||
|
|
||||||
{
|
{
|
||||||
:new
|
:new
|
||||||
(fn []
|
(fn [{: content-filter-store}]
|
||||||
(var foreground-view nil)
|
(var foreground-view nil)
|
||||||
(let [listeners (Listeners.new)
|
(let [listeners (Listeners.new)
|
||||||
relay-events []
|
relay-events []
|
||||||
@ -87,6 +88,7 @@
|
|||||||
(listeners:notify event-name $1))))
|
(listeners:notify event-name $1))))
|
||||||
views {}]
|
views {}]
|
||||||
{
|
{
|
||||||
|
:content-filter-store content-filter-store
|
||||||
:listen (fn [_ name fun]
|
:listen (fn [_ name fun]
|
||||||
(if (not (. relay-events name))
|
(if (not (. relay-events name))
|
||||||
(each [_ v (pairs views)]
|
(each [_ v (pairs views)]
|
||||||
|
@ -1,7 +1,33 @@
|
|||||||
(local { : Gtk : Gdk : WebKit2 : cairo } (require :lgi))
|
(local { : Gtk : Gdk : WebKit2 : cairo : GLib } (require :lgi))
|
||||||
|
|
||||||
(local Listeners (require :listeners))
|
(local Listeners (require :listeners))
|
||||||
|
|
||||||
|
(fn load-easylist-json [store cb]
|
||||||
|
(print "loading easylist from json")
|
||||||
|
(with-open [f (io.open "easylist_min_content_blocker.json" "r")]
|
||||||
|
(let [blocks (f:read "*a")]
|
||||||
|
(store:save "easylist"
|
||||||
|
(GLib.Bytes blocks)
|
||||||
|
nil
|
||||||
|
(fn [self res]
|
||||||
|
(cb (store:save_finish res)))))))
|
||||||
|
|
||||||
|
(fn load-adblocks [content-manager store]
|
||||||
|
(store:fetch_identifiers
|
||||||
|
nil
|
||||||
|
(fn [self res]
|
||||||
|
(let [ids (store:fetch_identifiers_finish res)
|
||||||
|
found (icollect [_ id (pairs ids)] (= id "easylist"))]
|
||||||
|
(if (> (# found) 0)
|
||||||
|
(store:load "easylist" nil
|
||||||
|
(fn [self res]
|
||||||
|
(content-manager:add_filter
|
||||||
|
(store:load_finish res))))
|
||||||
|
(load-easylist-json
|
||||||
|
store
|
||||||
|
(fn [filter]
|
||||||
|
(content-manager:add_filter filter))))))))
|
||||||
|
|
||||||
(fn scale-surface [source image-width image-height]
|
(fn scale-surface [source image-width image-height]
|
||||||
(let [scaled (cairo.ImageSurface.create
|
(let [scaled (cairo.ImageSurface.create
|
||||||
cairo.Format.ARGB32
|
cairo.Format.ARGB32
|
||||||
@ -34,7 +60,8 @@
|
|||||||
|
|
||||||
{
|
{
|
||||||
:new
|
:new
|
||||||
#(let [listeners (Listeners.new)
|
(fn [{: content-filter-store}]
|
||||||
|
(let [listeners (Listeners.new)
|
||||||
props {}
|
props {}
|
||||||
widget (WebKit2.WebView {
|
widget (WebKit2.WebView {
|
||||||
:on_notify
|
:on_notify
|
||||||
@ -44,7 +71,8 @@
|
|||||||
(tset props pspec.name val)
|
(tset props pspec.name val)
|
||||||
(listeners:notify pspec.name val))))
|
(listeners:notify pspec.name val))))
|
||||||
})]
|
})]
|
||||||
;;(load-adblocks webview.user_content_manager content-filter-store)
|
(when content-filter-store
|
||||||
|
(load-adblocks widget.user_content_manager content-filter-store))
|
||||||
{
|
{
|
||||||
:listen #(listeners:add $2 $3)
|
:listen #(listeners:add $2 $3)
|
||||||
:visit (fn [self url]
|
:visit (fn [self url]
|
||||||
@ -58,5 +86,5 @@
|
|||||||
|
|
||||||
:properties props
|
:properties props
|
||||||
:widget widget
|
:widget widget
|
||||||
})
|
}))
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user