Compare commits

...

2 Commits

Author SHA1 Message Date
Fierelier a5785dbfee Add addons: history, settings*, content* 2023-03-01 12:55:33 +01:00
Fierelier 2ebbdcbae2 Create WebView without WebContext, as it has assigned one anyways 2023-03-01 12:54:20 +01:00
13 changed files with 146 additions and 5 deletions

View File

@ -8,10 +8,9 @@ gi.require_version("Gtk","3.0")
gi.require_version("WebKit2","4.0")
from gi.repository import Gtk,WebKit2
webContext = WebKit2.WebContext()
def createWebView(*args,**kwargs):
return WebKit2.WebView.new_with_context(webContext,*args,**kwargs)
webView = WebKit2.WebView.new()
return webView
def init():
global event

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

@ -18,9 +18,8 @@ def onFavicon(webView,_):
favicon = Gdk.pixbuf_get_from_surface(favicon,0,0,favicon.get_width(),favicon.get_height())
window.set_icon(favicon)
mfp.require("browser").webContext.set_favicon_database_directory(None)
def onWebviewCreated(webView):
onFavicon(webView,None)
webView.props.web_context.set_favicon_database_directory(None)
webView.connect("notify::favicon",onFavicon)
eventHandler["webview:created"] = onWebviewCreated

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