parkouss / webmacs

webmacs - keyboard driven (emacs key bindings) browser, https://webmacs.readthedocs.io/en/latest/
GNU General Public License v3.0
157 stars 21 forks source link

Question : javascript #118

Closed deb75 closed 1 year ago

deb75 commented 5 years ago

Hello,

Is there an option or command to disable/enable javascript ?

Regards

TLATER commented 5 years ago

Hi, I've been working on this, see issue #102 - currently lack the time to actually do much on it, but will probably do some work once my exam period ends.

Feel free to comment on approach and suchlike there, but for all intents and purposes, this is a duplicate!

deb75 commented 5 years ago

From the issue you pointed out and following this link https://doc.qt.io/qt-5/qwebenginesettings.html, there is a setting called QWebEngineSettings::JavascriptEnabled . Is it accessible from webmacs settings ?

Good luck for your exams :-)

TLATER commented 5 years ago

I was going to simply answer, but I can't cobble together the correct snippet.

What you should know about webmacs is that its configuration file allows you to literally modify the browser as it's running, so you can literally import QWebEngineSettings from PyQt5 and simply disable JavaScript on that object. The main difficulty is finding the import magic to get the right object ;p

It's not that hard, and certainly done somewhere in the current code, so browse the source a bit and you'll likely figure it out.

As an example, this is how you set up a hidpi screen:

from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QApplication
QApplication.setAttribute(Qt.AA_EnableHighDpiScaling, True)

That said, flat-out disabling JavaScript will likely break webmacs, since it relies on running bits of JavaScript too, and even if it doesn't it will leave 99% of the web in an unusable state if you don't have a bit more finesse. Hence the slightly bigger feature (:

All of that said, would you mind closing this issue and continuing any relevant discussion (say, in case you manage to write a bit of code that does it and want to share) on the original issue? It's best to keep these things in one place, I've already duplicated information (albeit a bit more verbose).