Condense NoJS feature into Anonymous View
Enabling NoJS now removes Javascript from the Anonymous View, rather than creating a separate option.
This commit is contained in:
parent
e7b70dd34d
commit
efd505f192
|
@ -85,7 +85,7 @@ class Filter:
|
||||||
self,
|
self,
|
||||||
user_key: str,
|
user_key: str,
|
||||||
config: Config,
|
config: Config,
|
||||||
root_url: str,
|
root_url='',
|
||||||
page_url='',
|
page_url='',
|
||||||
mobile=False) -> None:
|
mobile=False) -> None:
|
||||||
self.config = config
|
self.config = config
|
||||||
|
@ -340,9 +340,10 @@ class Filter:
|
||||||
for style in soup.find_all('style'):
|
for style in soup.find_all('style'):
|
||||||
style.string = clean_css(style.string, self.page_url)
|
style.string = clean_css(style.string, self.page_url)
|
||||||
|
|
||||||
# Convert remote stylesheets to style tags
|
# TODO: Convert remote stylesheets to style tags and proxy all
|
||||||
for link in soup.find_all('link', attrs={'rel': 'stylesheet'}):
|
# remote requests
|
||||||
print(link)
|
# for link in soup.find_all('link', attrs={'rel': 'stylesheet'}):
|
||||||
|
# print(link)
|
||||||
|
|
||||||
def update_styling(self, soup) -> None:
|
def update_styling(self, soup) -> None:
|
||||||
# Remove unnecessary button(s)
|
# Remove unnecessary button(s)
|
||||||
|
@ -438,11 +439,8 @@ class Filter:
|
||||||
link['href'] = filter_link_args(q)
|
link['href'] = filter_link_args(q)
|
||||||
|
|
||||||
# Add alternate viewing options for results
|
# Add alternate viewing options for results
|
||||||
if self.config.nojs:
|
|
||||||
append_nojs(link)
|
|
||||||
|
|
||||||
if self.config.anon_view:
|
if self.config.anon_view:
|
||||||
append_anon_view(link)
|
append_anon_view(link, self.config.nojs)
|
||||||
|
|
||||||
if self.config.new_tab:
|
if self.config.new_tab:
|
||||||
link['target'] = '_blank'
|
link['target'] = '_blank'
|
||||||
|
|
|
@ -22,6 +22,11 @@ li {
|
||||||
color: var(--whoogle-dark-text) !important;
|
color: var(--whoogle-dark-text) !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.anon-view {
|
||||||
|
color: var(--whoogle-dark-text) !important;
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
|
||||||
textarea {
|
textarea {
|
||||||
background: var(--whoogle-dark-page-bg) !important;
|
background: var(--whoogle-dark-page-bg) !important;
|
||||||
color: var(--whoogle-dark-text) !important;
|
color: var(--whoogle-dark-text) !important;
|
||||||
|
|
|
@ -22,6 +22,11 @@ li {
|
||||||
color: var(--whoogle-text) !important;
|
color: var(--whoogle-text) !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.anon-view {
|
||||||
|
color: var(--whoogle-text) !important;
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
|
||||||
textarea {
|
textarea {
|
||||||
background: var(--whoogle-page-bg) !important;
|
background: var(--whoogle-page-bg) !important;
|
||||||
color: var(--whoogle-text) !important;
|
color: var(--whoogle-text) !important;
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
"config-block-url": "Block by URL",
|
"config-block-url": "Block by URL",
|
||||||
"config-block-url-help": "Use regex",
|
"config-block-url-help": "Use regex",
|
||||||
"config-theme": "Theme",
|
"config-theme": "Theme",
|
||||||
"config-nojs": "Show NoJS Links",
|
"config-nojs": "Remove Javascript in \"Anonymous View\"",
|
||||||
"config-anon-view": "Show \"Anonymous View\" Links",
|
"config-anon-view": "Show \"Anonymous View\" Links",
|
||||||
"config-dark": "Dark Mode",
|
"config-dark": "Dark Mode",
|
||||||
"config-safe": "Safe Search",
|
"config-safe": "Safe Search",
|
||||||
|
|
|
@ -188,20 +188,22 @@ def append_nojs(result: BeautifulSoup) -> None:
|
||||||
result.append(nojs_link)
|
result.append(nojs_link)
|
||||||
|
|
||||||
|
|
||||||
def append_anon_view(result: BeautifulSoup) -> None:
|
def append_anon_view(result: BeautifulSoup, nojs: bool) -> None:
|
||||||
"""Appends an 'anonymous view' for a search result, where all site
|
"""Appends an 'anonymous view' for a search result, where all site
|
||||||
contents are viewed through Whoogle as a proxy.
|
contents are viewed through Whoogle as a proxy.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
result: The search result to append an anon view link to
|
result: The search result to append an anon view link to
|
||||||
|
nojs: Remove Javascript from Anonymous View
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
None
|
None
|
||||||
|
|
||||||
"""
|
"""
|
||||||
av_link = BeautifulSoup(features='html.parser').new_tag('a')
|
av_link = BeautifulSoup(features='html.parser').new_tag('a')
|
||||||
av_link['href'] = f'/{Endpoint.window}?location=' + result['href']
|
av_link['href'] = f'/{Endpoint.window}?nojs={1 if nojs else 0}&location={result["href"]}'
|
||||||
av_link.string = ' Anonymous View'
|
av_link.string = ' Anonymous View'
|
||||||
|
av_link['class'] = 'anon-view'
|
||||||
result.append(av_link)
|
result.append(av_link)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user