def filter_request(self, info: interceptor.Request) -> None: """Block the given request if necessary.""" if self._is_blocked(request_url=info.request_url, first_party_url=info.first_party_url): logger.debug("Request to {} blocked by host blocker.".format( info.request_url.host())) info.block()
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()
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()
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()
def filter_request(self, info: interceptor.Request) -> None: """Block the given request if necessary.""" if self._is_blocked(request_url=info.request_url, first_party_url=info.first_party_url): logger.info("Request to {} blocked by host blocker." .format(info.request_url.host())) info.block()
def filter_request(self, info: interceptor.Request) -> None: """Block the given request if necessary.""" if self._is_blocked(info.request_url, info.first_party_url, info.resource_type): logger.debug( "Request to %s blocked by ad blocker.", info.request_url.toDisplayString(), ) info.block()
def filter_yt(info: interceptor.Request): """Block the given request if necessary.""" url = info.request_url print("Received request " + url.scheme() + "://" + url.host() + " " + url.query()) if (url.host() == 'start.mpv'): activated = True info.block() host = url.host() query = url.query() q = parse_qs(query) # os.system("terminal -e 'bash -c \""+q.url+" "+q.x+" "+q.y+" \"'") print('Intecepted MPV-start') print(q) # os.system("mpv https://www.youtube.com/watch?v=lSjhdfRYNsA") subprocess.Popen([ "/home/max/git/dotfiles/qutebrowser/start-mpv.sh", q['url'][0], str(int(q['right'][0]) - int(q['left'][0])), str(int(q['bottom'][0]) - int(q['top'][0])), q['left'][0], q['top'][0] ]) if (url.host() == 'move.mpv'): info.block() host = url.host() query = url.query() q = parse_qs(query) # os.system("terminal -e 'bash -c \""+q.url+" "+q.x+" "+q.y+" \"'") print('Intecepted MPV-move') print(q) # os.system("mpv https://www.youtube.com/watch?v=lSjhdfRYNsA") subprocess.Popen([ "/home/max/git/dotfiles/qutebrowser/move-mpv.sh", q['url'][0], str(int(q['right'][0]) - int(q['left'][0])), str(int(q['bottom'][0]) - int(q['top'][0])), q['left'][0], q['top'][0] ]) if (url.host() == 'stop.mpv'): activated = False info.block() host = url.host() query = url.query() q = parse_qs(query) # os.system("terminal -e 'bash -c \""+q.url+" "+q.x+" "+q.y+" \"'") print('Intecepted MPV-start') print(q) # os.system("mpv https://www.youtube.com/watch?v=lSjhdfRYNsA") subprocess.Popen([ "/home/max/git/dotfiles/qutebrowser/stop-mpv.sh", q['url'][0], str(int(q['right'][0]) - int(q['left'][0])), str(int(q['bottom'][0]) - int(q['top'][0])), q['left'][0], q['top'][0] ]) if ('googlevideo.com' in url.host() and False): info.block()
def jblock_intercept(info: interceptor.Request): global jblock_buckets global blocking_time global blocking_num global slowest_urls global psl global whitelist_urls global block_history # we may be making the first request. # We don't pre-initialize buckets as when starting qutebrowser over IPC, # config is run first. We only want to add overhead to the main instance. # TODO fix race condition which allows 'jblock_reload' to run multiple # times on startup Unfortunately doing this properly with locks results in # a large regression, but it should be possible to do this more correctly # without locks. if jblock_buckets is None or psl is None: # First time init jblock_reload(quiet=True) start_time = time.perf_counter() request_scheme = info.request_url.scheme() if info.is_blocked or request_scheme in {"data", "blob"}: # Don't do anything if we are already blocked or a internal url return request_host, context_host = info.request_url.host( ), info.first_party_url.host() if (whitelist_urls and any( map(functools.partial(operator.contains, whitelist_urls), tools.domain_variants(context_host)))): # This context is whitelisted, don't block. return first_party = psl.fp_domain(context_host) == psl.fp_domain(request_host) url = info.request_url.toString() if hasattr(info, 'resource_type') and info.resource_type is not None: resource_type = info.resource_type else: # On a backend that does not support resource_type. Technically this # is un-supported, as adblock lists need this to work properly. resource_type = interceptor.ResourceType.unknown options = { 'domain': context_host, 'script': resource_type == interceptor.ResourceType.script, 'image': resource_type == interceptor.ResourceType.image, 'stylesheet': resource_type == interceptor.ResourceType.stylesheet, 'object': resource_type == interceptor.ResourceType.object, 'subdocument': resource_type in { interceptor.ResourceType.sub_frame, interceptor.ResourceType.sub_resource }, 'document': resource_type == interceptor.ResourceType.main_frame, '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)
def filter_yt(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()
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()
def jblock_intercept(info: interceptor.Request): global jblock_buckets global blocking_time global blocking_num global slowest_urls global psl global whitelist_urls global block_history # we may be making the first request. # We don't pre-initialize buckets as when starting qutebrowser over IPC, config is run first. # We only want to add overhead to the main instance. if jblock_buckets is None: # First time init jblock_reload(quiet=True) start_time = time.perf_counter() request_scheme = info.request_url.scheme() if info.is_blocked or request_scheme in {"data", "blob"}: # Don't do anything if we are already blocked or a internal url return request_host, context_host = info.request_url.host( ), info.first_party_url.host() if whitelist_urls and any( map( functools.partial(operator.contains, whitelist_urls), tools.domain_variants(context_host), )): # This context is whitelisted, don't block. return first_party = psl.fp_domain(context_host) == psl.fp_domain(request_host) url = info.request_url.toString() if hasattr(info, "resource_type") and info.resource_type is not None: resource_type = info.resource_type else: # On a backend that does not support resource_type. Technically this # is un-supported, as adblock lists need this to work properly. resource_type = interceptor.ResourceType.unknown options = { "domain": context_host, "script": resource_type == interceptor.ResourceType.script, "image": resource_type == interceptor.ResourceType.image, "stylesheet": resource_type == interceptor.ResourceType.stylesheet, "object": resource_type == interceptor.ResourceType.object, "subdocument": resource_type in { interceptor.ResourceType.sub_frame, interceptor.ResourceType.sub_resource }, "document": resource_type == interceptor.ResourceType.main_frame, "third-party": not first_party, } if jblock_buckets.should_block(url, options): info.block() block_history.appendleft("%s %s" % ("BLOCKED: ", url)) else: block_history.appendleft("%s %s" % ("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)
def filter_youtube(info: interceptor.Request): """Block request to get Advt.""" url = info.request_url if (url.host() == 'www.youtube.com' and url.path() == '/get_video_info' and '&adformat=' in url.query()): info.block()