Add addons: history, settings*, content*

This commit is contained in:
Fierelier 2023-03-01 12:55:33 +01:00
parent 2ebbdcbae2
commit a5785dbfee
11 changed files with 143 additions and 0 deletions

View File

@ -1,6 +1,19 @@
userModules
title
favicon
history
settings
settingsNoHardwareAccel
settingsPerformanceCPU
settingsPerformanceRAM
content
contentStylePerformance01
contentStylePerformance02
#contentStylePerformance03
#contentStylePerformance04
contextMenu
contextMenuWindow
contextMenuGo

View File

@ -0,0 +1,11 @@
import gi
gi.require_version("WebKit2","4.0")
from gi.repository import Gtk,WebKit2
browser = mfp.require("browser")
contentManager = WebKit2.UserContentManager.new()
def f(*args,**kwargs):
webView = WebKit2.WebView.new_with_user_content_manager(contentManager)
return webView
browser.createWebView = f

View File

@ -0,0 +1,16 @@
# These styles are quite universal, and shouldn't limit anything functionally.
import gi
gi.require_version("WebKit2","4.0")
from gi.repository import WebKit2
browser = mfp.require("browser")
styleSheet = WebKit2.UserStyleSheet.new("""
* {
outline: none !important;
box-shadow: none !important;
text-shadow: none !important;
image-rendering: pixelated !important;
}
""",WebKit2.UserContentInjectedFrames.ALL_FRAMES,WebKit2.UserStyleLevel.USER,None,None)
browser.contentManager.add_style_sheet(styleSheet)

View File

@ -0,0 +1,15 @@
# Still pretty universal, but can cause usability issues in very rare circumstances.
import gi
gi.require_version("WebKit2","4.0")
from gi.repository import WebKit2
browser = mfp.require("browser")
styleSheet = WebKit2.UserStyleSheet.new("""
* {
border-radius: 0px !important;
filter: none !important;
mask: none !important;
}
""",WebKit2.UserContentInjectedFrames.ALL_FRAMES,WebKit2.UserStyleLevel.USER,None,None)
browser.contentManager.add_style_sheet(styleSheet)

View File

@ -0,0 +1,16 @@
# Somewhat likely to cause functional issues.
import gi
gi.require_version("WebKit2","4.0")
from gi.repository import WebKit2
browser = mfp.require("browser")
styleSheet = WebKit2.UserStyleSheet.new("""
* {
animation-iteration-count: 1 !important;
animation-duration: 1ms !important;
transition-duration: 1ms !important;
transition-delay: 0s !important;
}
""",WebKit2.UserContentInjectedFrames.ALL_FRAMES,WebKit2.UserStyleLevel.USER,None,None)
browser.contentManager.add_style_sheet(styleSheet)

View File

@ -0,0 +1,16 @@
# Quite likely to cause functional issues.
import gi
gi.require_version("WebKit2","4.0")
from gi.repository import WebKit2
browser = mfp.require("browser")
styleSheet = WebKit2.UserStyleSheet.new("""
* {
transform: none !important;
-webkit-transform: none !important;
background-repeat: no-repeat !important;
background-attachment: local !important;
}
""",WebKit2.UserContentInjectedFrames.ALL_FRAMES,WebKit2.UserStyleLevel.USER,None,None)
browser.contentManager.add_style_sheet(styleSheet)

View File

@ -0,0 +1,26 @@
import os
eventHandler = mfp.Bunch()
browser = mfp.require("browser")
config = mfp.require("config")
if not os.path.isdir(config.paths[0]):
os.makedirs(config.paths[0])
fh = open(os.path.join(config.paths[0],"history.txt"),"a")
url = ""
def onUrlChanged(obj,_):
global url
url = obj.get_uri()
fh.write("\n" + url)
fh.flush()
def onTitleChanged(obj,_):
global url
fh.write("\n" + url + " " + obj.get_title())
fh.flush()
def onWebviewCreated(webView):
webView.connect("notify::title",onTitleChanged)
webView.connect("notify::uri",onUrlChanged)
eventHandler["webview:created"] = onWebviewCreated

View File

@ -0,0 +1,14 @@
import gi
gi.require_version("WebKit2","4.0")
from gi.repository import WebKit2
browser = mfp.require("browser")
eventHandler = mfp.Bunch()
settings = WebKit2.Settings.new()
#settings.props.enable_media = False
#settings.props.user_agent = "UwU"
def onWebviewCreated(webView):
webView.set_settings(settings)
eventHandler["webview:created"] = onWebviewCreated

View File

@ -0,0 +1,10 @@
import gi
gi.require_version("WebKit2","4.0")
from gi.repository import WebKit2
import os
browser = mfp.require("browser")
os.environ["LIBGL_ALWAYS_SOFTWARE"] = "1"
settings = browser.addon.addons.settings.settings.props
settings.enable_accelerated_2d_canvas = False
settings.hardware_acceleration_policy = WebKit2.HardwareAccelerationPolicy.NEVER

View File

@ -0,0 +1,3 @@
browser = mfp.require("browser")
settings = browser.addon.addons.settings.settings.props
settings.enable_smooth_scrolling = False

View File

@ -0,0 +1,3 @@
browser = mfp.require("browser")
settings = browser.addon.addons.settings.settings.props
settings.enable_dns_prefetching = False