Esempio n. 1
0
def init(context: apitypes.InitContext) -> None:
    """Initialize the host blocker."""
    global _host_blocker
    _host_blocker = HostBlocker(data_dir=context.data_dir,
                                config_dir=context.config_dir,
                                has_basedir=context.args.basedir is not None)
    _host_blocker.read_hosts()
    interceptor.register(_host_blocker.filter_request)
Esempio n. 2
0
def init(context: apitypes.InitContext) -> None:
    """Initialize the host blocker."""
    global _host_blocker
    _host_blocker = HostBlocker(data_dir=context.data_dir,
                                config_dir=context.config_dir,
                                has_basedir=context.args.basedir is not None)
    _host_blocker.read_hosts()
    interceptor.register(_host_blocker.filter_request)
Esempio n. 3
0
def init(context: apitypes.InitContext) -> None:
    """Initialize the Brave ad blocker."""
    global ad_blocker

    adblock_info = version.MODULE_INFO["adblock"]
    if not adblock_info.is_usable():
        # We want 'adblock' to be an optional dependency. If the module is
        # not installed or is outdated, we simply keep the `ad_blocker` global at
        # `None`.
        _possibly_show_missing_dependency_warning()
        return

    ad_blocker = BraveAdBlocker(data_dir=context.data_dir,
                                has_basedir=context.args.basedir is not None)
    ad_blocker.read_cache()
    interceptor.register(ad_blocker.filter_request)
Esempio n. 4
0

# Any return value other than a literal 'False' means we redirected
REDIRECT_MAP = {
    "reddit.com": operator.methodcaller('setHost', 'teddit.net'),
    "www.reddit.com": operator.methodcaller('setHost', 'teddit.net'),

    # Pastebins
    "paste.debian.net": _debian_redir,
    "paste.the-compiler.org": _the_compiler_redir,
    # Causes an infinite loop if the paste does not exist...
    "pastebin.com": _pastebin_redir,
    "hasteb.in": _hastebin_redir,
    "hastebin.com": _hastebin_redir,
}  # type: typing.Dict[str, typing.Callable[..., typing.Optional[bool]]]


def int_fn(info: interceptor.Request):
    """Block the given request if necessary."""
    if (info.resource_type != interceptor.ResourceType.main_frame
            or info.request_url.scheme() in {"data", "blob"}):
        return
    url = info.request_url
    redir = REDIRECT_MAP.get(url.host())
    if redir is not None and redir(url) is not False:
        message.info("Redirecting to " + url.toString())
        info.redirect(url)


interceptor.register(int_fn)
Esempio n. 5
0
import sys, os, platform
from qutebrowser.api import interceptor
import dracula.dracula

# Youtube adblock
def filter_yt(info: interceptor.Request):
	"""Block the given request if necessary."""
	url = info.request_url
	if (url.host() == 'www.youtube.com' and
			url.path() == '/get_video_info' and
			'&adformat=' in url.query()):
		info.block()

interceptor.register(filter_yt)

# Misc config
#c.qt.args=["ignore-gpu-blacklist", "enable-gpu-rasterization", "enable-native-gpu-memory-buffers", "num-raster-threads=8"]

config.set("tabs.background", True)

# Binds
config.bind('<Ctrl-Shift-y>', 'hint links spawn mpv {hint-url}')
config.set('content.headers.user_agent', 'Mozilla/5.0 (X11; Linux x86_64; rv:57.0) Gecko/20100101 Firefox/77.0', 'https://accounts.google.com/*')

config.bind('J', 'tab-prev')
config.bind('K', 'tab-next')
#config.set('statusbar.hide', True)

config.unbind('b')
config.bind('ba', 'bookmark-add')
config.bind('bd', 'bookmark-del')
Esempio n. 6
0
from qutebrowser.api import interceptor


# Youtube
def filterYoutube(info: interceptor.Request):
    """Block the given request if necessary."""
    # and url.path() == "/get_video_info"

    url = info.request_url
    if "youtube.com" in url.host() and "adformat=" in url.query():
        info.block()

    # if "googlevideo.com" in url.host() and "expire=" in url.query():
    #     info.block()


interceptor.register(filterYoutube)
Esempio n. 7
0
        'third-party': not first_party,
    }
    if jblock_buckets.should_block(url, options):
        info.block()
        block_history.appendleft("BLOCKED:  " + url)
    else:
        block_history.appendleft("ALLOWED:  " + url)
    time_change = time.perf_counter() - start_time
    blocking_time += time_change
    blocking_num += 1
    heapq.heappush(slowest_urls, (time_change, url))
    if len(slowest_urls) > JBLOCK_SLOWEST_URL_WINDOW:
        heapq.heappop(slowest_urls)


interceptor.register(jblock_intercept)


@cmdutils.register()
def jblock_print_buckets():
    """Print a summary of the hottest buckets."""
    global jblock_buckets
    if jblock_buckets is None:
        return
    message.info(jblock_buckets.summary_str())


@cmdutils.register()
def jblock_print_init_time():
    """Print initialization time."""
    message.info(str(init_time))
Esempio n. 8
0
qutebrowser settings for video
for more settings check out
https://qutebrowser.org/doc/help/settings.html
"""


# ================== Youtube Add Blocking ======================= {{{
def pipe_to_mpv(info: interceptor.Request):
    """Block the given request if necessary."""
    url = info.request_url
    if (url.host() == "www.youtube.com" and url.path() == "/watch"
            and "v" in url.query()):
        subprocess.call(["mpv", "url.toString()"])


interceptor.register(pipe_to_mpv)
# }}}
# =================== Launch Qutebrowser from Dmenu ====== {{{

# }}}
# ====================== xresources ======================= {{{
# taken from https://qutebrowser.org/doc/help/configuring.html

c.url.searchengines = {
    'DEFAULT': 'https://google.com/search?hl=en&q={}',
    '!d': 'https://duckduckgo.com/?ia=web&q={}',
    '!fb': 'https://www.facebook.com/s.php?q={}',
    '!gh': 'https://github.com/search?o=desc&q={}&s=stars',
    '!gi': 'https://www.google.com/search?tbm=isch&q={}&tbs=imgo:1',
    '!yt': 'https://www.youtube.com/results?search_query={}'
}
Esempio n. 9
0
c.colors.statusbar.command.private.bg = "#444444"


# Custom redirects
def redirect(info: interceptor.Request):
    url = info.request_url
    if url.host() == 'www.reddit.com':
        url.setHost('old.reddit.com')
        try:
            info.redirect(url)
            message.info("Redirecting to " + url.toString())
        except RedirectException:
            pass


interceptor.register(redirect)

# Prevent meta redirects in www.elpais.com.uy
if not hasattr(AbstractTab, '_old_on_navigation_request'):
    AbstractTab._old_on_navigation_request = AbstractTab._on_navigation_request


def new_on_navigation_request(self, navigation):
    self._old_on_navigation_request(navigation)
    if self.url().host() in (
            'www.elpais.com.uy',
            'www.ovaciondigital.com.uy',
            'negocios.elpais.com.uy',
            'www.tvshow.com.uy',
    ):
        if navigation.url.path().startswith('/user/suscripcion'):
Esempio n. 10
0
# ==== yt add-blocking ====== {{{
# taken from Gavin Freeborn
# https://odysee.com/@GavinFreeborn:d/why-i-use-qutebrowser-and-how-i:3


def ytfilter(info: interceptor.Request):
    url = info.request_url
    if(url.host() == "www.youtube.com"
       and url.path() == "/get_video_info"
       and "&adformat" in url.query()
       ):
        info.block()


interceptor.register(ytfilter)
# }}}

# ==== fonts ====== {{{
c.fonts.default_family = '"FiraCode Nerd Font"'
c.fonts.default_size = '13pt'
c.fonts.completion.entry = '13pt "FiraCode Nerd Font"'
c.fonts.debug_console = '13pt "FiraCode Nerd Font"'
c.fonts.prompts = 'default_size sans-serif'
c.fonts.statusbar = '13pt "FiraCode Nerd Font"'
# }}}

# ==== bindings ====== {{{
config.bind(
    ',ap', 'config-cycle content.user_stylesheets '
    '~/.config/qutebrowser/css/apprentice-all-sites.css ""')