Skip to content

Instantly share code, notes, and snippets.

@DefaultUser
Last active May 10, 2019 20:47
Show Gist options
  • Save DefaultUser/4af066d2c6638ec1e602ea5fdb4656c3 to your computer and use it in GitHub Desktop.
Save DefaultUser/4af066d2c6638ec1e602ea5fdb4656c3 to your computer and use it in GitHub Desktop.
import Falkon
from PySide2 import QtCore
from PySide2 import QtWebEngineCore
class BlockmatrixInterceptor(Falkon.UrlInterceptor):
def interceptRequest(self, info):
print(info.requestUrl())
return
#return False
#if info.resourceType() != QtWebEngineCore.QWebEngineUrlRequestInfo.ResourceTypeMainFrame:
# info.block(True)
class BlockmatrixPlugin(Falkon.PluginInterface, QtCore.QObject):
def init(self, state, settingsPath):
print(f"loading BlockmatrixPlugin {state} {settingsPath}")
self.interceptor = BlockmatrixInterceptor(self)
Falkon.MainApplication.instance().networkManager().installUrlInterceptor(self.interceptor)
def testPlugin(self):
return True
# def acceptNavigationRequest(self, page, url, navtype, isMainFrame):
# print(f"BlockmatrixPlugin nav request: {page}, {url}, {navtype}, {isMainFrame}")
# if isMainFrame:
# return True
# return False
def unload(self):
print("unloading BlockmatrixPlugin")
Falkon.registerPlugin(BlockmatrixPlugin())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment