2024-03-26, change verion code.

master
CHUN YU YAO 2024-04-07 21:24:21 +08:00
parent 949d192b36
commit 017a88334d
6 changed files with 70 additions and 9 deletions

View File

@ -44,7 +44,7 @@ except Exception as exc:
print(exc)
pass
CONST_APP_VERSION = "MaxBot (2024.03.25)"
CONST_APP_VERSION = "MaxBot (2024.03.26)"
CONST_MAXBOT_ANSWER_ONLINE_FILE = "MAXBOT_ONLINE_ANSWER.txt"
CONST_MAXBOT_CONFIG_FILE = "settings.json"
@ -115,6 +115,21 @@ CONST_WEBDRIVER_TYPE_DP = "DrissionPage"
CONST_WEBDRIVER_TYPE_NODRIVER = "nodriver"
CONST_CHROME_FAMILY = ["chrome","edge","brave"]
USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36"
CONST_PREFS_DICT = {
"credentials_enable_service": False,
"in_product_help.snoozed_feature.IPH_LiveCaption.is_dismissed": True,
"in_product_help.snoozed_feature.IPH_LiveCaption.last_dismissed_by": 4,
"media_router.show_cast_sessions_started_by_other_devices.enabled": False,
"net.network_prediction_options": 3,
"privacy_guide.viewed": True,
"profile.default_content_setting_values.notifications": 2,
"profile.default_content_setting_values.sound": 2,
"profile.name": CONST_APP_VERSION,
"profile.password_manager_enabled": False,
"safebrowsing.enabled":False,
"safebrowsing.enhanced":False,
"sync.autofill_wallet_import_enabled_migrated":False,
"translate":{"enabled": False}}
warnings.simplefilter('ignore',InsecureRequestWarning)
ssl._create_default_https_context = ssl._create_unverified_context
@ -292,7 +307,7 @@ def get_chrome_options(webdriver_path, config_dict):
chrome_options.add_experimental_option("excludeSwitches", ['enable-automation'])
# Deprecated chrome option is ignored: useAutomationExtension
#chrome_options.add_experimental_option('useAutomationExtension', False)
chrome_options.add_experimental_option("prefs", {"credentials_enable_service": False, "profile.password_manager_enabled": False, "profile.name": CONST_APP_VERSION, "translate":{"enabled": False}})
chrome_options.add_experimental_option("prefs", CONST_PREFS_DICT)
if len(config_dict["advanced"]["proxy_server_port"]) > 2:
chrome_options.add_argument('--proxy-server=%s' % config_dict["advanced"]["proxy_server_port"])
@ -455,7 +470,7 @@ def get_uc_options(uc, config_dict, webdriver_path):
options.add_argument("--no-sandbox")
options.add_argument("--no-service-autorun")
options.add_argument("--password-store=basic")
options.add_experimental_option("prefs", {"credentials_enable_service": False, "profile.password_manager_enabled": False, "profile.name": CONST_APP_VERSION, "translate":{"enabled": False}})
options.add_experimental_option("prefs", CONST_PREFS_DICT)
if len(config_dict["advanced"]["proxy_server_port"]) > 2:
options.add_argument('--proxy-server=%s' % config_dict["advanced"]["proxy_server_port"])

View File

@ -24,7 +24,7 @@ import webbrowser
import util
CONST_APP_VERSION = "MaxBot (2024.03.25)"
CONST_APP_VERSION = "MaxBot (2024.03.26)"
CONST_MAXBOT_LAUNCHER_FILE = "config_launcher.json"
CONST_MAXBOT_CONFIG_FILE = "settings.json"

View File

@ -29,7 +29,7 @@ from datetime import datetime
import util
CONST_APP_VERSION = "MaxBot (2024.03.25)"
CONST_APP_VERSION = "MaxBot (2024.03.26)"
CONST_MAXBOT_CONFIG_FILE = "settings.json"
CONST_MAXBOT_KKTIX_CONFIG_FILE = "kktix.json"

View File

@ -32,7 +32,7 @@ except Exception as exc:
print(exc)
pass
CONST_APP_VERSION = "MaxBot (2024.03.25)"
CONST_APP_VERSION = "MaxBot (2024.03.26)"
CONST_MAXBOT_ANSWER_ONLINE_FILE = "MAXBOT_ONLINE_ANSWER.txt"
CONST_MAXBOT_CONFIG_FILE = "settings.json"
@ -1392,12 +1392,33 @@ def get_maxbot_plus_extension_path():
return config_filepath
def get_maxbot_block_extension_path():
extension_path = "webdriver/Maxblockplus_1.0.0/"
if platform.system() == 'Windows':
extension_path = extension_path.replace("/","\\")
app_root = util.get_app_root()
config_filepath = os.path.join(app_root, extension_path)
#print("config_filepath:", config_filepath)
# check extesion mainfest
path = pathlib.Path(config_filepath)
if path.exists():
if path.is_dir():
#print("found extension dir")
for item in path.rglob("manifest.*"):
path = item.parent
#print("final path:", path)
return config_filepath
def get_extension_config(config_dict):
default_lang = "zh-TW"
no_sandbox=True
conf = Config(browser_args=get_nodriver_browser_args(), lang=default_lang, no_sandbox=no_sandbox, headless=config_dict["advanced"]["headless"])
if config_dict["advanced"]["chrome_extension"]:
conf.add_extension(get_maxbot_plus_extension_path())
conf.add_extension(get_maxbot_block_extension_path())
return conf
async def nodrver_block_urls(tab, config_dict):
@ -1504,9 +1525,33 @@ def nodriver_overwrite_prefs(conf, prefs_dict={}):
if not os.path.exists(prefs_filepath):
os.mkdir(prefs_filepath)
prefs_filepath = os.path.join(prefs_filepath,"Preferences")
prefs_dict["in_product_help"]={}
prefs_dict["in_product_help"]["snoozed_feature"]={}
prefs_dict["in_product_help"]["snoozed_feature"]["IPH_LiveCaption"]={}
prefs_dict["in_product_help"]["snoozed_feature"]["IPH_LiveCaption"]["is_dismissed"]=True
prefs_dict["in_product_help"]["snoozed_feature"]["IPH_LiveCaption"]["last_dismissed_by"]=4
prefs_dict["media_router"]={}
prefs_dict["media_router"]["show_cast_sessions_started_by_other_devices"]={}
prefs_dict["media_router"]["show_cast_sessions_started_by_other_devices"]["enabled"]=False
prefs_dict["net"]={}
prefs_dict["net"]["network_prediction_options"]=3
prefs_dict["privacy_guide"]={}
prefs_dict["privacy_guide"]["viewed"]=True
prefs_dict["privacy_sandbox"]={}
prefs_dict["privacy_sandbox"]["first_party_sets_enabled"]=False
prefs_dict["profile"]={}
prefs_dict["profile"]["cookie_controls_mode"]=1
prefs_dict["profile"]["default_content_setting_values"]={}
prefs_dict["profile"]["default_content_setting_values"]["notifications"]=2
prefs_dict["profile"]["default_content_setting_values"]["sound"]=2
prefs_dict["profile"]["name"]=CONST_APP_VERSION
prefs_dict["profile"]["password_manager_enabled"]=False
prefs_dict["safebrowsing"]={}
prefs_dict["safebrowsing"]["enabled"]=False
prefs_dict["safebrowsing"]["enhanced"]=False
prefs_dict["sync"]={}
prefs_dict["sync"]["autofill_wallet_import_enabled_migrated"]=False
json_str = json.dumps(prefs_dict)
with open(prefs_filepath, 'w') as outfile:
outfile.write(json_str)
@ -1521,6 +1566,8 @@ def nodriver_overwrite_prefs(conf, prefs_dict={}):
"memory-saver-multi-state-mode@1",
"modal-memory-saver@1"
]
state_dict["dns_over_https"]={}
state_dict["dns_over_https"]["mode"]="off"
json_str = json.dumps(state_dict)
with open(state_filepath, 'w') as outfile:
outfile.write(json_str)
@ -1729,7 +1776,6 @@ async def main(args):
if len(facebook_account) > 4:
await nodriver_facebook_login(tab, facebook_account, facebook_password)
def cli():
parser = argparse.ArgumentParser(
description="MaxBot Aggument Parser")

View File

@ -41,7 +41,7 @@ try:
except Exception as exc:
pass
CONST_APP_VERSION = "MaxBot (2024.03.25)"
CONST_APP_VERSION = "MaxBot (2024.03.26)"
CONST_MAXBOT_ANSWER_ONLINE_FILE = "MAXBOT_ONLINE_ANSWER.txt"
CONST_MAXBOT_CONFIG_FILE = "settings.json"

View File

@ -6,9 +6,9 @@ import platform
import random
import re
import socket
import subprocess
import sys
import threading
import subprocess
from typing import Optional
import requests