Go to file
Jimmy ab50ad735b Greasemonkey: isolates scripts' writes to window
Since the global namespace of javascript in the browser is accessible
there where issues with scripts clobbering things that the page expected
to be attributes of window pages clobbering things that userscripts
saved to `window`. The latter was occuring with OneeChan. OneeChan was
setting `window.$` to a function that took a css selector and the 4chan
catalog script was setting `window.$` to some object. Since OneeChan was
set to run at document-start this broke OneeChan, switching it to
document-end broke scripts on 4chan.

I used OneeChan and 4chan-X on 4chan as the test case for this and
TamperMonkey as a guide for what is the correct way to handle scoping. I
didn't manage to pick apart just how TamperMonkey does what it does (I
think it might just be the environment that Chrome provides extensions
actually) but I got close to the same behaviour.

TamperMonkey provides a `window` object that appears to be what the
global window looked like before the webpage modified it. The global
scope though does have the pages modifications accessible. If the script
assigns something to an attribute `window` it can see that attribute in
the global scope. This implementation differs from that one in that, to
the scipt, `window` and the global scope always look the same, and that
is the same as the global scope looks in the environment provided by
TamperMonkey.

I am using the ES6 `Proxy` feature to allow the `window` object to look
like the actual (unsafe) one while allowing writing to it that doesn't
clobber the unsafe one. I am then using the ES4 `with` function to make
attributes of that window (proxy) object visible in the scope chain.
There may be other ways to do this without using `with` by using nested
functions and setting `this` creatively. There are notes around
alleging `with` to be various states of uncool[1].

I also ran into an issue where a userscript calling
`window.addEventListener(...)` would fail with `TypeError: Illegal
Execution` which is apparently due to `this` not being set correctly. I
looked at the functions which threw that error and those that didn't and
am using whether they have a `prototype` attribute or not to tell
whether I need to bind them with `window` as `this`. I am not sure how
correct that is but it worked for all the cases I ran into.

[1]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/with
2018-05-20 18:42:40 +12:00
.github Add myself to CODEOWNERS to watch for caret code 2018-01-19 22:25:58 +06:00
doc Update changelog 2018-05-17 17:53:15 +02:00
icons Add 32bit color for Windows icon 2018-03-21 23:13:26 +02:00
misc Update hypothesis from 3.56.5 to 3.56.9 2018-05-14 18:48:20 +02:00
qutebrowser Greasemonkey: isolates scripts' writes to window 2018-05-20 18:42:40 +12:00
scripts Remove 32-bit check in build_release.py 2018-04-16 08:33:01 +02:00
tests Add Python executable to :version 2018-05-14 22:13:15 +02:00
www Use https:// links for qutebrowser.org 2017-11-14 10:43:05 +01:00
.appveyor.yml Use PyQt 5.10 on AppVeyor 2018-02-07 10:53:13 +01:00
.codecov.yml Make codecov.yml hidden 2017-09-17 21:40:35 +02:00
.coveragerc Add an utils.Unreachable exception 2017-12-15 16:33:47 +01:00
.editorconfig Add basic editorconfig for enforcing style 2016-04-06 02:55:34 -04:00
.flake8 Update comment 2018-04-24 09:53:41 +02:00
.gitignore Add .pytest_cache to .gitignore 2018-02-07 12:04:42 +01:00
.pydocstylerc Add a .pydocstylerc. 2016-01-30 23:39:55 +01:00
.pylintrc pylint: More config adjustments 2017-12-15 23:17:28 +01:00
.pyup.yml Switch pyup to Mondays 2017-08-24 05:50:33 +02:00
.travis.yml travis: Test Python 3.5 with Qt 5.7.1 2018-03-08 12:28:10 +01:00
LICENSE Fix more file move issues 2017-09-17 21:54:42 +02:00
MANIFEST.in Include requirements files in built release 2018-03-14 21:10:35 +01:00
pytest.ini Improve marker descriptions 2018-02-26 07:56:51 +01:00
qutebrowser.py Update copyright years 2018-02-05 12:19:50 +01:00
README.asciidoc Update recommended Qt version in readme 2018-03-28 08:48:18 +02:00
requirements.txt Update attrs from 17.4.0 to 18.1.0 2018-05-07 18:39:17 +02:00
setup.py Add Python 3.7 compatibility to setup.py 2018-02-10 20:08:33 +01:00
tox.ini Force PyQt 5.10.0 with "tox -e mkvenv-pypi" 2018-03-11 20:47:01 +01:00

// If you are reading this in plaintext or on PyPi:
//
// A rendered version is available at:
// https://github.com/qutebrowser/qutebrowser/blob/master/README.asciidoc

qutebrowser
===========

// QUTE_WEB_HIDE
image:icons/qutebrowser-64x64.png[qutebrowser logo] *A keyboard-driven, vim-like browser based on PyQt5 and Qt.*

image:https://img.shields.io/pypi/l/qutebrowser.svg?style=flat["license badge",link="https://github.com/qutebrowser/qutebrowser/blob/master/LICENSE"]
image:https://img.shields.io/pypi/v/qutebrowser.svg?style=flat["version badge",link="https://pypi.python.org/pypi/qutebrowser/"]
image:https://travis-ci.org/qutebrowser/qutebrowser.svg?branch=master["Build Status", link="https://travis-ci.org/qutebrowser/qutebrowser"]
image:https://ci.appveyor.com/api/projects/status/5pyauww2k68bbow2/branch/master?svg=true["AppVeyor build status", link="https://ci.appveyor.com/project/qutebrowser/qutebrowser"]
image:https://codecov.io/github/qutebrowser/qutebrowser/coverage.svg?branch=master["coverage badge",link="https://codecov.io/github/qutebrowser/qutebrowser?branch=master"]

link:https://www.qutebrowser.org[website] | link:https://blog.qutebrowser.org[blog] | https://github.com/qutebrowser/qutebrowser/blob/master/doc/faq.asciidoc[FAQ] | https://www.qutebrowser.org/doc/contributing.html[contributing] | link:https://github.com/qutebrowser/qutebrowser/releases[releases] | https://github.com/qutebrowser/qutebrowser/blob/master/doc/install.asciidoc[installing]
// QUTE_WEB_HIDE_END

qutebrowser is a keyboard-focused browser with a minimal GUI. It's based
on Python and PyQt5 and free software, licensed under the GPL.

It was inspired by other browsers/addons like dwb and Vimperator/Pentadactyl.

Screenshots
-----------

image:doc/img/main.png["screenshot 1",width=300,link="doc/img/main.png"]
image:doc/img/downloads.png["screenshot 2",width=300,link="doc/img/downloads.png"]
image:doc/img/completion.png["screenshot 3",width=300,link="doc/img/completion.png"]
image:doc/img/hints.png["screenshot 4",width=300,link="doc/img/hints.png"]

Downloads
---------

See the https://github.com/qutebrowser/qutebrowser/releases[github releases
page] for available downloads and the link:doc/install.asciidoc[INSTALL] file for
detailed instructions on how to get qutebrowser running on various platforms.

Documentation
-------------

In addition to the topics mentioned in this README, the following documents are
available:

* https://raw.githubusercontent.com/qutebrowser/qutebrowser/master/doc/img/cheatsheet-big.png[Key binding cheatsheet]: +
image:https://raw.githubusercontent.com/qutebrowser/qutebrowser/master/doc/img/cheatsheet-small.png["qutebrowser key binding cheatsheet",link="https://raw.githubusercontent.com/qutebrowser/qutebrowser/master/doc/img/cheatsheet-big.png"]
* link:doc/quickstart.asciidoc[Quick start guide]
* https://www.shortcutfoo.com/app/dojos/qutebrowser[Free training course] to remember those key bindings
* link:doc/faq.asciidoc[Frequently asked questions]
* link:doc/help/configuring.asciidoc[Configuring qutebrowser]
* link:doc/contributing.asciidoc[Contributing to qutebrowser]
* link:doc/install.asciidoc[Installing qutebrowser]
* link:doc/changelog.asciidoc[Change Log]
* link:doc/stacktrace.asciidoc[Reporting segfaults]
* link:doc/userscripts.asciidoc[How to write userscripts]

Getting help
------------

You can get help in the IRC channel
irc://irc.freenode.org/#qutebrowser[`#qutebrowser`] on
http://freenode.net/[Freenode]
(https://webchat.freenode.net/?channels=#qutebrowser[webchat]), or by writing a
message to the
https://lists.schokokeks.org/mailman/listinfo.cgi/qutebrowser[mailinglist] at
mailto:qutebrowser@lists.qutebrowser.org[].

There's also an https://lists.schokokeks.org/mailman/listinfo.cgi/qutebrowser-announce[announce-only mailinglist]
at mailto:qutebrowser-announce@lists.qutebrowser.org[] (the announcements also
get sent to the general qutebrowser@ list).

If you're a reddit user, there's a
https://www.reddit.com/r/qutebrowser/[/r/qutebrowser] subreddit there.

Contributions / Bugs
--------------------

You want to contribute to qutebrowser? Awesome! Please read
link:doc/contributing.asciidoc[the contribution guidelines] for details and
useful hints.

If you found a bug or have a feature request, you can report it in several
ways:

* Use the built-in `:report` command or the automatic crash dialog.
* Open an issue in the Github issue tracker.
* Write a mail to the
https://lists.schokokeks.org/mailman/listinfo.cgi/qutebrowser[mailinglist] at
mailto:qutebrowser@lists.qutebrowser.org[].

For security bugs, please contact me directly at mail@qutebrowser.org, GPG ID
https://www.the-compiler.org/pubkey.asc[0x916eb0c8fd55a072].

Requirements
------------

The following software and libraries are required to run qutebrowser:

* http://www.python.org/[Python] 3.5 or newer (3.6 recommended)
* http://qt.io/[Qt] 5.7.1 or newer (5.10 recommended) with the following modules:
  - QtCore / qtbase
  - QtQuick (part of qtbase in some distributions)
  - QtSQL (part of qtbase in some distributions)
  - QtOpenGL
  - QtWebEngine, or
  - QtWebKit - only the
    link:https://github.com/annulen/webkit/wiki[updated fork] (5.212) is
    supported
* http://www.riverbankcomputing.com/software/pyqt/intro[PyQt] 5.7.0 or newer
  (5.10 recommended) for Python 3
* https://pypi.python.org/pypi/setuptools/[pkg_resources/setuptools]
* http://fdik.org/pyPEG/[pyPEG2]
* http://jinja.pocoo.org/[jinja2]
* http://pygments.org/[pygments]
* https://github.com/yaml/pyyaml[PyYAML]
* http://www.attrs.org/[attrs]

The following libraries are optional:

* http://cthedot.de/cssutils/[cssutils] (for an improved `:download --mhtml`
  with QtWebKit).
* On Windows, https://pypi.python.org/pypi/colorama/[colorama] for colored log
  output.
* http://asciidoc.org/[asciidoc] to generate the documentation for the `:help`
  command, when using the git repository (rather than a release).

See link:doc/install.asciidoc[the documentation] for directions on how to
install qutebrowser and its dependencies.

Donating
--------

Working on qutebrowser is a very rewarding hobby, but like (nearly) all hobbies
it also costs some money. Namely I have to pay for the server and domain, and
do occasional hardware upgrades footnote:[It turned out a 160 GB SSD is rather
small - the VMs and custom Qt builds I use for testing/developing qutebrowser
need about 100 GB of space].

If you want to give me a beer or a pizza back, I'm trying to make it as easy as
possible for you to do so. If some other way would be easier for you, please
get in touch!

* PayPal: me@the-compiler.org
* Bitcoin: link:bitcoin:1PMzbcetAHfpxoXww8Bj5XqquHtVvMjJtE[1PMzbcetAHfpxoXww8Bj5XqquHtVvMjJtE]

Authors
-------

qutebrowser's primary author is Florian Bruhin (The Compiler), but qutebrowser
wouldn't be what it is without the help of
https://github.com/qutebrowser/qutebrowser/graphs/contributors[hundreds of contributors]!

Additionally, the following people have contributed graphics:

* Jad/link:http://yelostudio.com[yelo] (new icon)
* WOFall (original icon)
* regines (key binding cheatsheet)

Also, thanks to everyone who contributed to one of qutebrowser's
link:doc/backers.asciidoc[crowdfunding campaigns]!

Similar projects
----------------

Many projects with a similar goal as qutebrowser exist.
Most of them were inspirations for qutebrowser in some way, thanks for that!

Active
~~~~~~

* https://fanglingsu.github.io/vimb/[vimb] (C, GTK+ with WebKit2)
* https://luakit.github.io/luakit/[luakit] (C/Lua, GTK+ with WebKit2)
* http://surf.suckless.org/[surf] (C, GTK+ with WebKit1/WebKit2)
* http://www.uzbl.org/[uzbl] (C, GTK+ with WebKit1/WebKit2)
* Chrome/Chromium addons:
  https://github.com/1995eaton/chromium-vim[cVim],
  http://vimium.github.io/[Vimium],
  https://github.com/brookhong/Surfingkeys[Surfingkeys],
  https://key.saka.io/[Saka Key]
* Firefox addons (based on WebExtensions):
  https://addons.mozilla.org/en-GB/firefox/addon/vimium-ff/[Vimium-FF] (experimental),
  https://key.saka.io[Saka Key],
  https://github.com/ueokande/vim-vixen[Vim Vixen],
  https://github.com/shinglyu/QuantumVim[QuantumVim],
  https://github.com/cmcaine/tridactyl[Tridactyl] (working
  on a https://bugzilla.mozilla.org/show_bug.cgi?id=1215061[better API] for
  keyboard integration in Firefox).

Inactive
~~~~~~~~

* https://bitbucket.org/portix/dwb[dwb] (C, GTK+ with WebKit1,
https://bitbucket.org/portix/dwb/pull-requests/22/several-cleanups-to-increase-portability/diff[unmaintained] -
main inspiration for qutebrowser)
* http://sourceforge.net/p/vimprobable/wiki/Home/[vimprobable] (C, GTK+ with
  WebKit1)
* http://pwmt.org/projects/jumanji/[jumanji] (C, GTK+ with WebKit1)
* http://conkeror.org/[conkeror] (Javascript, Emacs-like, XULRunner/Gecko)
* Firefox addons (not based on WebExtensions or no recent activity):
  http://www.vimperator.org/[Vimperator],
  http://5digits.org/pentadactyl/[Pentadactyl],
  https://github.com/akhodakivskiy/VimFx[VimFx],
* Chrome/Chromium addons:
  https://chrome.google.com/webstore/detail/vichrome/gghkfhpblkcmlkmpcpgaajbbiikbhpdi?hl=en[ViChrome],
  https://github.com/jinzhu/vrome[Vrome]

License
-------

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <https://www.gnu.org/licenses/gpl-3.0.txt>.

pdf.js
------

qutebrowser optionally uses https://github.com/mozilla/pdf.js/[pdf.js] to
display PDF files in the browser. Windows releases come with a bundled pdf.js.

pdf.js is distributed under the terms of the Apache License. You can
find a copy of the license in `qutebrowser/3rdparty/pdfjs/LICENSE` (in the
Windows release or after running `scripts/dev/update_3rdparty.py`), or online
http://www.apache.org/licenses/LICENSE-2.0.html[here].