block facebook network.

master
Max 2023-11-09 12:26:33 +08:00 committed by GitHub
parent d1227e05fb
commit 89ebc7592b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 21 deletions

View File

@ -55,7 +55,7 @@ import webbrowser
import chromedriver_autoinstaller import chromedriver_autoinstaller
CONST_APP_VERSION = "MaxBot (2023.11.06)" CONST_APP_VERSION = "MaxBot (2023.11.07)"
CONST_MAXBOT_CONFIG_FILE = "settings.json" CONST_MAXBOT_CONFIG_FILE = "settings.json"
CONST_MAXBOT_LAST_URL_FILE = "MAXBOT_LAST_URL.txt" CONST_MAXBOT_LAST_URL_FILE = "MAXBOT_LAST_URL.txt"
@ -461,21 +461,6 @@ def load_chromdriver_normal(config_dict, driver_type):
print(exc3) print(exc3)
pass pass
if driver_type=="stealth":
from selenium_stealth import stealth
# Selenium Stealth settings
stealth(driver,
languages=["zh-TW", "zh"],
vendor="Google Inc.",
platform="Win32",
webgl_vendor="Intel Inc.",
renderer="Intel Iris OpenGL Engine",
fix_hairline=True,
)
#print("driver capabilities", driver.capabilities)
return driver return driver
def clean_uc_exe_cache(): def clean_uc_exe_cache():
@ -781,10 +766,7 @@ def get_driver_by_config(config_dict):
print("create web driver object fail @_@;") print("create web driver object fail @_@;")
else: else:
try: try:
NETWORK_BLOCKED_URLS = ['*.ttf' NETWORK_BLOCKED_URLS = ['*/adblock.js'
,'*.otf'
,'*/favicon.ico'
,'*/adblock.js'
,'*/google_ad_block.js' ,'*/google_ad_block.js'
,'*google-analytics.*' ,'*google-analytics.*'
,'*googletagmanager.*' ,'*googletagmanager.*'
@ -799,7 +781,6 @@ def get_driver_by_config(config_dict):
,'*.twitter.com/i/*' ,'*.twitter.com/i/*'
,'*platform.twitter.com/*' ,'*platform.twitter.com/*'
,'*syndication.twitter.com/*' ,'*syndication.twitter.com/*'
,'*.fbcdn.net/*'
,'*youtube.com/*' ,'*youtube.com/*'
,'*player.youku.*' ,'*player.youku.*'
,'*e2elog.fetnet.net*'] ,'*e2elog.fetnet.net*']
@ -807,6 +788,9 @@ def get_driver_by_config(config_dict):
if config_dict["advanced"]["hide_some_image"]: if config_dict["advanced"]["hide_some_image"]:
NETWORK_BLOCKED_URLS.append('*.woff') NETWORK_BLOCKED_URLS.append('*.woff')
NETWORK_BLOCKED_URLS.append('*.woff2') NETWORK_BLOCKED_URLS.append('*.woff2')
NETWORK_BLOCKED_URLS.append('*.ttf')
NETWORK_BLOCKED_URLS.append('*.otf')
NETWORK_BLOCKED_URLS.append('*.ico')
NETWORK_BLOCKED_URLS.append('*ticketimg2.azureedge.net/image/ActivityImage/*') NETWORK_BLOCKED_URLS.append('*ticketimg2.azureedge.net/image/ActivityImage/*')
NETWORK_BLOCKED_URLS.append('*static.tixcraft.com/images/activity/*') NETWORK_BLOCKED_URLS.append('*static.tixcraft.com/images/activity/*')
NETWORK_BLOCKED_URLS.append('*static.tixcraft.com/images/field/*') NETWORK_BLOCKED_URLS.append('*static.tixcraft.com/images/field/*')
@ -816,6 +800,10 @@ def get_driver_by_config(config_dict):
NETWORK_BLOCKED_URLS.append('*static.ticketmaster.com/images/field/*') NETWORK_BLOCKED_URLS.append('*static.ticketmaster.com/images/field/*')
NETWORK_BLOCKED_URLS.append('*azureedge.net/QWARE_TICKET//images/*') NETWORK_BLOCKED_URLS.append('*azureedge.net/QWARE_TICKET//images/*')
if config_dict["advanced"]["block_facebook_network"]:
NETWORK_BLOCKED_URLS.append('*facebook.com/*')
NETWORK_BLOCKED_URLS.append('*.fbcdn.net/*')
driver.execute_cdp_cmd('Network.setBlockedURLs', {"urls": NETWORK_BLOCKED_URLS}) driver.execute_cdp_cmd('Network.setBlockedURLs', {"urls": NETWORK_BLOCKED_URLS})
driver.execute_cdp_cmd('Network.enable', {}) driver.execute_cdp_cmd('Network.enable', {})
if 'kktix.c' in homepage: if 'kktix.c' in homepage: