adji

Adji's a Decisive and Joyful Internet browser
git clone https://noxz.tech/git/adji.git
adji

commit: 97d4368eb546d838da6d4f7caff47d2a7394a97d
parent: 
author: Chris Noxz <chris@noxz.tech>
date:   Thu, 9 Mar 2023 11:20:05 +0100
initial commit
A.gitignore2+
ALICENSE674+++++++++++
AMakefile45+
Aadji.1476++++++++
Abrowser.c1268++++++++++++++++++++
Abrowser.h528++++++++
Aconfig.h54+
Aconfig.mk17+
Awe_redirect.c169+++
9 files changed, 3233 insertions(+)
diff --git a/.gitignore b/.gitignore
@@ -0,0 +1,2 @@
+adji
+we_redirect.so
diff --git a/LICENSE b/LICENSE
@@ -0,0 +1,674 @@
+                    GNU GENERAL PUBLIC LICENSE
+                       Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+                            Preamble
+
+  The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+  The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works.  By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users.  We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors.  You can apply it to
+your programs, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+  To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights.  Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received.  You must make sure that they, too, receive
+or can get the source code.  And you must show them these terms so they
+know their rights.
+
+  Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+  For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software.  For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+  Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so.  This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software.  The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable.  Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products.  If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+  Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary.  To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+                       TERMS AND CONDITIONS
+
+  0. Definitions.
+
+  "This License" refers to version 3 of the GNU General Public License.
+
+  "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+  "The Program" refers to any copyrightable work licensed under this
+License.  Each licensee is addressed as "you".  "Licensees" and
+"recipients" may be individuals or organizations.
+
+  To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy.  The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+  A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+  To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy.  Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+  To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies.  Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+  An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License.  If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+  1. Source Code.
+
+  The "source code" for a work means the preferred form of the work
+for making modifications to it.  "Object code" means any non-source
+form of a work.
+
+  A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+  The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form.  A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+  The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities.  However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work.  For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+  The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+  The Corresponding Source for a work in source code form is that
+same work.
+
+  2. Basic Permissions.
+
+  All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met.  This License explicitly affirms your unlimited
+permission to run the unmodified Program.  The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work.  This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+  You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force.  You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright.  Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+  Conveying under any other circumstances is permitted solely under
+the conditions stated below.  Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+  3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+  No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+  When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+  4. Conveying Verbatim Copies.
+
+  You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+  You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+  5. Conveying Modified Source Versions.
+
+  You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+    a) The work must carry prominent notices stating that you modified
+    it, and giving a relevant date.
+
+    b) The work must carry prominent notices stating that it is
+    released under this License and any conditions added under section
+    7.  This requirement modifies the requirement in section 4 to
+    "keep intact all notices".
+
+    c) You must license the entire work, as a whole, under this
+    License to anyone who comes into possession of a copy.  This
+    License will therefore apply, along with any applicable section 7
+    additional terms, to the whole of the work, and all its parts,
+    regardless of how they are packaged.  This License gives no
+    permission to license the work in any other way, but it does not
+    invalidate such permission if you have separately received it.
+
+    d) If the work has interactive user interfaces, each must display
+    Appropriate Legal Notices; however, if the Program has interactive
+    interfaces that do not display Appropriate Legal Notices, your
+    work need not make them do so.
+
+  A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit.  Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+  6. Conveying Non-Source Forms.
+
+  You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+    a) Convey the object code in, or embodied in, a physical product
+    (including a physical distribution medium), accompanied by the
+    Corresponding Source fixed on a durable physical medium
+    customarily used for software interchange.
+
+    b) Convey the object code in, or embodied in, a physical product
+    (including a physical distribution medium), accompanied by a
+    written offer, valid for at least three years and valid for as
+    long as you offer spare parts or customer support for that product
+    model, to give anyone who possesses the object code either (1) a
+    copy of the Corresponding Source for all the software in the
+    product that is covered by this License, on a durable physical
+    medium customarily used for software interchange, for a price no
+    more than your reasonable cost of physically performing this
+    conveying of source, or (2) access to copy the
+    Corresponding Source from a network server at no charge.
+
+    c) Convey individual copies of the object code with a copy of the
+    written offer to provide the Corresponding Source.  This
+    alternative is allowed only occasionally and noncommercially, and
+    only if you received the object code with such an offer, in accord
+    with subsection 6b.
+
+    d) Convey the object code by offering access from a designated
+    place (gratis or for a charge), and offer equivalent access to the
+    Corresponding Source in the same way through the same place at no
+    further charge.  You need not require recipients to copy the
+    Corresponding Source along with the object code.  If the place to
+    copy the object code is a network server, the Corresponding Source
+    may be on a different server (operated by you or a third party)
+    that supports equivalent copying facilities, provided you maintain
+    clear directions next to the object code saying where to find the
+    Corresponding Source.  Regardless of what server hosts the
+    Corresponding Source, you remain obligated to ensure that it is
+    available for as long as needed to satisfy these requirements.
+
+    e) Convey the object code using peer-to-peer transmission, provided
+    you inform other peers where the object code and Corresponding
+    Source of the work are being offered to the general public at no
+    charge under subsection 6d.
+
+  A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+  A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling.  In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage.  For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product.  A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+  "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source.  The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+  If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information.  But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+  The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed.  Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+  Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+  7. Additional Terms.
+
+  "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law.  If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+  When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it.  (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.)  You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+  Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+    a) Disclaiming warranty or limiting liability differently from the
+    terms of sections 15 and 16 of this License; or
+
+    b) Requiring preservation of specified reasonable legal notices or
+    author attributions in that material or in the Appropriate Legal
+    Notices displayed by works containing it; or
+
+    c) Prohibiting misrepresentation of the origin of that material, or
+    requiring that modified versions of such material be marked in
+    reasonable ways as different from the original version; or
+
+    d) Limiting the use for publicity purposes of names of licensors or
+    authors of the material; or
+
+    e) Declining to grant rights under trademark law for use of some
+    trade names, trademarks, or service marks; or
+
+    f) Requiring indemnification of licensors and authors of that
+    material by anyone who conveys the material (or modified versions of
+    it) with contractual assumptions of liability to the recipient, for
+    any liability that these contractual assumptions directly impose on
+    those licensors and authors.
+
+  All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10.  If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term.  If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+  If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+  Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+  8. Termination.
+
+  You may not propagate or modify a covered work except as expressly
+provided under this License.  Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+  However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+  Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+  Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License.  If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+  9. Acceptance Not Required for Having Copies.
+
+  You are not required to accept this License in order to receive or
+run a copy of the Program.  Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance.  However,
+nothing other than this License grants you permission to propagate or
+modify any covered work.  These actions infringe copyright if you do
+not accept this License.  Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+  10. Automatic Licensing of Downstream Recipients.
+
+  Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License.  You are not responsible
+for enforcing compliance by third parties with this License.
+
+  An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations.  If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+  You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License.  For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+  11. Patents.
+
+  A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based.  The
+work thus licensed is called the contributor's "contributor version".
+
+  A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version.  For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+  Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+  In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement).  To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+  If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients.  "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+  If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+  A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License.  You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+  Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+  12. No Surrender of Others' Freedom.
+
+  If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all.  For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+  13. Use with the GNU Affero General Public License.
+
+  Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU Affero General Public License into a single
+combined work, and to convey the resulting work.  The terms of this
+License will continue to apply to the part which is the covered work,
+but the special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+  14. Revised Versions of this License.
+
+  The Free Software Foundation may publish revised and/or new versions of
+the GNU General Public License from time to time.  Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+  Each version is given a distinguishing version number.  If the
+Program specifies that a certain numbered version of the GNU General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation.  If the Program does not specify a version number of the
+GNU General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+  If the Program specifies that a proxy can decide which future
+versions of the GNU General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+  Later license versions may give you additional or different
+permissions.  However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+  15. Disclaimer of Warranty.
+
+  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+  16. Limitation of Liability.
+
+  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+  17. Interpretation of Sections 15 and 16.
+
+  If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+                     END OF TERMS AND CONDITIONS
+
+            How to Apply These Terms to Your New Programs
+
+  If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+  To do so, attach the following notices to the program.  It is safest
+to attach them to the start of each source file to most effectively
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the program's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    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/>.
+
+Also add information on how to contact you by electronic and paper mail.
+
+  If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
+
+    <program>  Copyright (C) <year>  <name of author>
+    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+    This is free software, and you are welcome to redistribute it
+    under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License.  Of course, your program's commands
+might be different; for a GUI interface, you would use an "about box".
+
+  You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU GPL, see
+<https://www.gnu.org/licenses/>.
+
+  The GNU General Public License does not permit incorporating your program
+into proprietary programs.  If your program is a subroutine library, you
+may consider it more useful to permit linking proprietary applications with
+the library.  If this is what you want to do, use the GNU Lesser General
+Public License instead of this License.  But first, please read
+<https://www.gnu.org/licenses/why-not-lgpl.html>.
diff --git a/Makefile b/Makefile
@@ -0,0 +1,45 @@
+.POSIX:
+
+include config.mk
+
+all: options ${__NAME__} we_redirect.so
+
+options:
+	@echo build options:
+	@echo "CFLAGS  = ${CFLAGS}"
+	@echo "CC      = ${CC}"
+
+${__NAME__}: browser.c config.h
+	${CC} ${CFLAGS} ${LDFLAGS} \
+		-o $@ $< \
+		`pkg-config --cflags --libs gtk+-3.0 glib-2.0 webkit2gtk-4.0`
+
+we_redirect.so: we_redirect.c
+	${CC} ${CFLAGS} ${LDFLAGS} \
+		-shared -o $@ -fPIC $< \
+		`pkg-config --cflags --libs glib-2.0 webkit2gtk-4.0`
+
+install: all
+	mkdir -v -p ${DESTDIR}${PREFIX}/bin
+	cp -v ${__NAME__} ${DESTDIR}${PREFIX}/bin
+	chmod 755 ${DESTDIR}${PREFIX}/bin/${__NAME__}
+	mkdir -v -p ${DESTDIR}${PREFIX}/man1
+	sed "s/VERSION/${VERSION}/g" < ${__NAME__}.1 > ${DESTDIR}${MANPREFIX}/man1/${__NAME__}.1
+	chmod 644 ${DESTDIR}${MANPREFIX}/man1/${__NAME__}.1
+	mkdir -v -p ${DESTDIR}${PREFIX}/lib/${__NAME__}/web_extensions
+	cp -v we_redirect.so ${DESTDIR}${PREFIX}/lib/${__NAME__}/web_extensions
+	@echo
+	@echo "== NOTE ========================================="
+	@printf " to enable we_redirect.so it must be copied from\n\
+	 ${DESTDIR}${PREFIX}/lib/${__NAME__}/web_extensions\n to\n\
+	 ~/.config/${__NAME__}/web_extensions\n"
+
+uninstall:
+	rm -rf ${DESTDIR}${PREFIX}/bin/${__NAME__}
+	rm -rf ${DESTDIR}${MANPREFIX}/man1/${__NAME__}.1
+	rm -rf ${DESTDIR}${PREFIX}/lib/${__NAME__}
+
+clean:
+	rm -f ${__NAME__} we_redirect.so
+
+.PHONY: all clean install uninstall
diff --git a/adji.1 b/adji.1
@@ -0,0 +1,476 @@
+.TH ADJI 1 adji\-VERSION
+.
+.SH NAME
+adji \- Adji's a Decisive and Joyful Internet browser
+.
+.SH SYNOPSIS
+.B adji
+.RB [ \-I ]
+.IR "" [ URI ...]
+.
+.SH DESCRIPTION
+.B adji
+is a simple, decisive and distraction free web browser using GTK+ 3,
+GLib and WebKit2GTK+. This web browser takes inspiration from other web
+browsers like
+.BR surf (1),
+.BR lariza (1)
+and
+.BR vimb (1).
+.
+.SH OPTIONS
+Along with the standard arguments for GTK+ 3 (see
+.BR gtk-options (7)),
+.B adji
+is equipped with the following options:
+.TP
+.B -I
+Implements an independent instance without any ipc configuration.
+.P
+If no URI are provided, the value of the enviornment variable
+.B ADJI_HOME_URI
+will be opened which defaults to \(lqabout:blank\(rq. Otherwise, any number of
+URIs may follow these options.
+.
+.SH ENVIRONMENT
+.B adji
+recognizes the following environment variables, in addition to the standard
+variables of GTK+ 3:
+.P
+.TP
+.B
+ADJI_ACCEPTED_LANGUAGES
+When sending an HTTP request, WebKit populates the \(lqAccepted-Language\(rq
+header based on the provided list of languages, which can be comma-separated
+(e.g. \(lqen_US,en_AU\(rq). If no languages are specified, WebKit will use
+.B en_US
+as the default.
+.TP
+.B
+ADJI_COOKIE_FILE
+By providing a path to a cookie file,
+.B adji
+will provide a method of sharing cookies between sessions and instances.
+.TP
+.B
+ADJI_DEFAULT_FONT
+Provides a method for specifying the default font inside the web view of
+.BR adji .
+If no default font is specified, WebKit will use
+.B sans-serif
+as the default.
+.TP
+.B
+ADJI_DEFAULT_FONT_SIZE
+Provides a method for specifying the default font size inside the web view of
+.BR adji .
+If no default font size is specified, WebKit will use
+.B 16
+as the default.
+.TP
+.B
+ADJI_DISABLE_AUTO_LOAD_IMAGES
+For a faster, or perhaps a more secure way of browsing the web, setting this
+variable provides a method of preventing images from loading automatically.
+.TP
+.B
+ADJI_DOWNLOAD_DIR
+This variable allows you to specify the directory to where all downloads are
+stored according to your preference. By default all downloads are stored at
+.BR /var/tmp .
+.TP
+.B
+ADJI_ENABLE_CONSOLE_TO_STDOUT
+Output that is printed to the web view console can be copied to
+.B STDOUT
+setting this variable.
+.TP
+.B
+ADJI_ENABLE_SMOOTH_SCROLLING
+By default
+.B adji
+disables the janky and annoying \(lqsmooth scrolling\(rq. If you for some
+reason like it, setting this variable will enable it.
+.TP
+.B
+ADJI_FIFO_NAME
+.B adji
+implements IPC configurations using named pipes in the file system. According
+to XDG standards, the files for these named pipes are stored as
+.IR /var/run/user/$UID/adji_$ADJI_FIFO_NAME.fifo .
+
+The
+.B $UID
+refers to the id of the user running
+.BR adji .
+.B $ADJI_FIFO_NAME
+refers to the value of this variable, which defaults to
+.BR default .
+By specifying this variable, parallel IPC configurations can be used. Be sure
+to also specify the $ADJI_STATE_FILE accordingly. If you do not, the IPC
+instances will conflict and overwrite the states of each other.
+.TP
+.B
+ADJI_HISTORY_FILE
+When set,
+.B adji
+will store each visited URI to the file specified.
+.TP
+.B
+ADJI_HOME_URI
+The URI that will be opened in new tabs if nothing else is specified. Defaults
+to
+.BR "about:blank" .
+.TP
+.B
+ADJI_MONOSPACE_FONT
+Provides a method for specifying the monospace font inside the web view of
+.BR adji .
+If no monospace font is specified, WebKit will use
+.B monospace
+as the default.
+.TP
+.B
+ADJI_PROXY_IGNORE
+When specifying a proxy URI,
+.B adji
+will send every HTTP requests through that URI. To exclude traffic to certain
+hosts from being sent through the specified proxy URI, this variable can be
+used to provide a comma-separated list of hosts to be ignored
+(e.g. \(lq127.0.0.1,noxz.tech\(rq).
+.TP
+.B
+ADJI_PROXY_URI
+By specifying a proxy URI,
+.B adji
+will send every HTTP requests through that URI. As an example a socks proxy for
+tor can be specified in this way \(lqsocks://127.0.0.1:9050\(rq.
+.TP
+.B
+ADJI_SANS_SERIF_FONT
+Provides a method for specifying the sans-serif font inside the web view of
+.BR adji .
+If no sans-serif font is specified, WebKit will use
+.B sans-serif
+as the default.
+.TP
+.B
+ADJI_SERIF_FONT
+Provides a method for specifying the serif font inside the web view of
+.BR adji .
+If no serif font is specified, WebKit will use
+.B serif
+as the default.
+.TP
+.B
+ADJI_SE_URI_FORMAT
+If an entry cannot be resolved as either a URI or a file path, a web search
+will be performed. To define the method of perforating this web search, a
+format can be utilized in the following manner, using
+.I http://ddg.gg
+as an example: \(lqhttps://ddg.gg?q=%s\(rq.
+One, and only one, string reference
+.BR "" ( %s )
+must be specified. The default value is
+.BR "https://ddg.gg?q=%s" .
+.TP
+.B
+ADJI_STATE_FILE
+By specifying a path to a state file,
+.B adji
+will save the state of open tabs for next time the program is run. Each time a
+tab is moved, updated or otherwise changed, the state of open tabs will be
+saved as a list of URIs. It is important to avoid using the same state file for
+multiple IPC configurations, as they will conflict and overwrite each other.
+.TP
+.B
+ADJI_VERBOSE
+If set, this feature is employed by
+.B we_redirect.so
+to verbosely output to
+.B STDERR
+which redirections are being.
+.TP
+.B
+ADJI_USER_AGENT
+By default,
+.B adji
+uses WebKit's default value for the user agent string. This variable can be
+utilized to specify an alternative user agent to the default one.
+.TP
+.B
+ADJI_ZOOM_LEVEL
+This variable can be utilized to set the zoom level of WebKit's viewports. The
+default value is
+.BR 1.0 .
+.
+.SH FILES
+These paths will be constructed using XDG variables.
+.TP
+.I ~/.config/adji/redirect
+Redirect rules used by
+.BR we_redirect.so .
+See the
+.B "WEB EXTENSION"
+section.
+.TP
+.I ~/.config/adji/exthandler
+.B adji
+has a built-in mechanism for externally handling URIs. You can use the file
+specified by the path to define how these URIs should be handled in a
+customized manner. A system call passes the URI as the first parameter.
+.TP
+.I ~/.config/adji/scripts
+Directory to store user scripts (JavaScript).
+.TP
+.I ~/.config/adji/styles
+Directory to store user style sheets (CSS).
+.TP
+.I ~/.config/adji/web_extensions
+Directory where WebKit will search for web extensions.
+.TP
+.I ~/.cache/adji
+.TQ
+.I ~/.cache/webkitgtk
+.TQ
+.I ~/.local/share/webkitgtk
+WebKitGTK will store its caches and local storage data in these directories.
+It is recommended to periodically clean these directories or mount them as
+some sort of volatile storage.
+.
+.SH USAGE
+.
+.SS Entry
+Entry refers to the entry/location/command bar at the bottom of the window.
+.TP
+.B Mod1\-h
+Navigate the caret to the left in the entry.
+.TP
+.B Mod1\-l
+Navigate the caret to the right in the entry.
+.TP
+.B Enter/Return
+The entered command or URI is resolved as appropriate. If no resolution is
+found, the entry is reverted back to its original value.
+.TB
+.B Escape
+The entry is reverted back to its original value.
+.
+.SS Tab bar
+.TP
+.B Button1
+When a tab is clicked, the corresponding pair of web view and entry will be
+made visible
+.TP
+.B Button2
+Clicking on a tab using the scroll wheel will close the pair of view and entry
+represented by that tab
+.TP
+.B Scroll wheel
+While hovering over the tab bar, scrolling the scroll wheel will allow you to
+move through tabs in the same direction as your scroll.
+.
+.SS Download bar
+The download bar remains hidden until a download is initiated. As the download
+progresses, the progress is shown and updated. Each download is represented by
+a button that can be clicked. During an active download, clicking the button
+will abort the download and remove the button. Once the download is complete,
+the button will simply be removed when clicked.
+.
+.SS Web view
+.TP
+.B Escape
+Stops the web rendering.
+.TP
+.B Button2
+Opens a hovered URI in a new tab.
+.TP
+.B Button8
+Go back in history.
+.TP
+.B Button9
+Go forward in history.
+.TP
+.B Mod1\-[Scroll Wheel]
+The zoom level of the current web view can be adjusted by scrolling while
+holding down the
+.B Mod1
+key.
+.
+.SS Global keyboard commands
+.TP
+.B Mod1\-Ctrl\-Shift\-j
+Move the current tab to the left (further down in the stack) within the tab
+bar.
+.TP
+.B Mod1\-Ctrl\-Shift\-K
+Move the current tab to the right (further up in the stack) within the tab
+bar.
+.TP
+.B Mod1\-Ctrl\-j
+Switch to the previous tab (the one to the left of the current one).
+.TP
+.B Mod1\-Ctrl\-k
+Switch to the next tab (the one to the right of the current one).
+.TP
+.B Mod1\-[1..n]
+Switch to the nth tab.
+.TP
+.B Mod1\-q
+Close the current tab.
+.TP
+.B Mod1\-w
+Go the specified home page.
+.TP
+.B Mod1\-t
+Open the specified home page within a new tab.
+.TP
+.B Mod1\-r
+Reload the page, bypassing the cache.
+.TP
+.B Mod1\-o
+Focus the entry bar for input.
+.TP
+.B Mod1\-/
+Initiate an in-page search.
+.TP
+.B Mod1\-n
+Perform a forward search within the context of the in-page search.
+.TP
+.B Mod1\-Shift\-n
+Perform a backwards search within the context of the in-page search.
+.TP
+.B Mod1\-b
+Toggle the visibility of the tab bar.
+.TP
+.B Mod1\-Shift\-h
+Go back in history.
+.TP
+.B Mod1\-Shift\-l
+Go forward in history.
+.TP
+.B Mod1\-s
+Toggle JavaScript functionality on or off.
+.TP
+.B Mod1\-c
+Toggle the TLS error policy between fail or ignore.
+.TP
+.B Mod1\-h
+Move/scroll towards the left on the page.
+.TP
+.B Mod1\-l
+Move/scroll towards the right on the page.
+.TP
+.B Mod1\-j
+Move/scroll towards the bottom of the page.
+.TP
+.B Mod1\-k
+Move/scroll towards the top of the page.
+.TP
+.B Mod1\-Shift\-g
+Go to the bottom of the page.
+.TP
+.B Mod1\-g
+Go to the top of the page.
+.TP
+.B Mod1\-p
+Open the print dialog.
+.
+.SS Entry commands
+Commands can be executed from the entry using a proceeding \(lq:\(rq.
+.B adji
+accepts two types of commands.
+.TP
+.B q
+If applicable, the program saves its state before quitting.
+.TP
+.B /
+To initiate an in-page search for a specific phrase, such as \(lqbanana\(rq,
+you would enter the succeeding phrase in the format of
+.BR :/banana .
+.
+.SS "User scripts"
+Upon successful loading of a page, the directory
+.I "~/.config/adji/scripts"
+is scanned, and every file with the \(lq.js\(rq extension is executed as a
+JavaScript file within the context of the loaded page.
+.
+.SS "User styles"
+Upon successful loading of a page, the directory
+.I "~/.config/adji/styles"
+is scanned, and every file with the \(lq.css\(rq extension is injected as a
+style sheet within the context of the loaded page. These style sheets can be
+utilized to customize the appearance of web pages according to your
+preferences.
+.
+.SH WEB EXTENSION
+.TP
+.B we_redirect.so
+To specify redirect rules in the redirect file, you should use the following
+format:
+.BR "/pattern/destination/" .
+Each rule should be written on a single line,
+and an arbitrary separator should be used to initialize each rule.
+This separator can be any character except for the \(lq#\(rq symbol,
+which is used for line comments. The
+.B pattern
+can be any regular expression pattern that matches a URI request. The
+.B destination
+can be left empty, or it can contain a replacement pattern that references
+regex groups from the pattern. If the destination is empty, the request will be
+terminated and act as a URI block.
+
+Regular expressions in terms of syntax and semantics are akin to Perl regular
+expressions.
+.
+.SH EXAMPLES
+.TP
+.B "adji -I"
+This command launches an independent
+.I adji
+instance without any IPC configuration. It will not load or save any states.
+However, if certain environment variables like
+.B ADJI_HISTORY_FILE
+and
+.B ADJI_COOKIE_FILE
+are defined, this instance will use them. Therefore, it cannot be considered
+completely isolated.
+
+To make such an instance more isolated the variables
+.BR ADJI_HISTORY_FILE ,
+.BR ADJI_COOKIE_FILE ,
+.BR XDG_CACHE_HOME ,
+and
+.BR XDG_DATA_HOME
+should be set to the value  \(lq/dev/null\(rq before executing the command.
+.TP
+.B "ADJI_PROXY_URI=socks://127.0.0.1:9050 adji -I"
+This command launches an independent
+.I adji
+instance without any IPC configuration. It routes every HTTP request through a
+designated proxy URI, specifically a tor socks proxy in this case. It will not
+load or save any states.
+
+However, to enhance privacy and isolation of this instance, measures must be
+taken to prevent data leakage through cookies or other sources. Additionally,
+consider using a more privacy-focused web browser.
+.
+.SH KNOWN ISSUES
+Double-clicking on a tab grabs the focus and prevents global key commands from
+functioning. This issue could be addressed by focusing the web view upon tab
+click events. However, as it is a minor problem and only present in a mouse 
+workflow, such a solution has not been implemented.
+.
+.SH AUTHOR
+Chris Noxz <chris@noxz.tech>
+.
+.SH COPYRIGHT
+Copyright \(co 2023 Chris Noxz.
+.P
+License: GPLv3+
+.P
+GNU GPL version 3 or later
+<https://www.gnu.org/licenses/licenses.html>.
+.P
+This is free software: you are free to change and redistribute it.
+There is NO WARRANTY, to the extent permitted by law.
diff --git a/browser.c b/browser.c
@@ -0,0 +1,1268 @@
+/**
+ * Copyright (C) 2023 Chris Noxz
+ * Author(s): Chris Noxz <chris@noxz.tech>
+ *
+ * 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/>.
+ */
+
+#include "browser.h"
+#include "config.h"
+
+
+struct Client*
+client_create(const gchar *uri, WebKitWebView *related_wv, gboolean show,
+              gboolean focus_tab)
+{
+	struct Client          *c;                  /* client to be */
+	gchar                  *u;                  /* translated uri */
+	GtkWidget              *e,                  /* event box */
+	                       *t;                  /* tab box */
+
+	/* communicate uri through ipc if constructed */
+	if (uri != NULL && gl.ipc == IPC_CLIENT) {
+		if (ipc_send((u = resolve_uri(uri))) <= 0 || ipc_send("\n") <= 0)
+			fprintf(stderr, __NAME__": Could not send message '%s'\n", u);
+		g_free(u);
+		return NULL; /* the request was handled elsewhere */
+	}
+
+	if (!(c = calloc(1, sizeof(struct Client))))
+		die("%s: fatal: calloc failed\n", __NAME__);
+
+	if (related_wv == NULL)
+		c->wv = webkit_web_view_new();
+	else
+		c->wv = webkit_web_view_new_with_related_view(related_wv);
+
+	/* connect signal callbacks */
+	CB(c->wv, "button-release-event",           cb_wv_hid, c);
+	CB(c->wv, "close",                          cb_wv_close, c);
+	CB(c->wv, "context-menu",                   cb_context_menu, c);
+	CB(c->wv, "create",                         cb_wv_create, NULL);
+	CB(c->wv, "decide-policy",                  cb_wv_decide_policy, NULL);
+	CB(c->wv, "key-press-event",                cb_wv_hid, c);
+	CB(c->wv, "load-changed",                   cb_wv_load_changed, c);
+	CB(c->wv, "load-failed-with-tls-errors",    cb_wv_tls_load_failed, c);
+	CB(c->wv, "mouse-target-changed",           cb_wv_hover, c);
+	CB(c->wv, "notify::estimated-load-progress",cb_wv_load_progress_changed, c);
+	CB(c->wv, "notify::favicon",                cb_favicon_changed, c);
+	CB(c->wv, "notify::title",                  cb_title_changed, c);
+	CB(c->wv, "notify::uri",                    cb_uri_changed, c);
+	CB(c->wv, "scroll-event",                   cb_wv_hid, c);
+	CB(c->wv, "web-process-crashed",            cb_wv_crashed, c);
+
+	/* get webkit settings */
+	c->settings = webkit_web_view_get_settings(WEBKIT_WEB_VIEW(c->wv));
+
+	/* load config into webkit settings */
+	if (CFG_S(UserAgent) != NULL)
+		g_object_set(
+		    G_OBJECT(c->settings), "user-agent", CFG_S(UserAgent), NULL
+		);
+	if (CFG_L(AcceptedLanguages) != NULL)
+		webkit_web_context_set_preferred_languages(
+		    webkit_web_view_get_context(WEBKIT_WEB_VIEW(c->wv)),
+		    CFG_L(AcceptedLanguages)
+		);
+	if (CFG_S(CookieFile) != NULL)
+		webkit_cookie_manager_set_persistent_storage(
+		    webkit_web_context_get_cookie_manager(
+		        webkit_web_view_get_context(WEBKIT_WEB_VIEW(c->wv))
+		    ),
+		    CFG_S(CookieFile),
+		    WEBKIT_COOKIE_PERSISTENT_STORAGE_TEXT
+		);
+	if (CFG_S(ProxyUri) != NULL)
+		webkit_website_data_manager_set_network_proxy_settings(
+		    webkit_web_view_get_website_data_manager(WEBKIT_WEB_VIEW(c->wv)),
+		    WEBKIT_NETWORK_PROXY_MODE_CUSTOM,
+		    webkit_network_proxy_settings_new(
+		        CFG_S(ProxyUri), CFG_L(ProxyIgnore)
+		    )
+		);
+	webkit_web_view_set_zoom_level(
+	    WEBKIT_WEB_VIEW(c->wv), CFG_F(ZoomLevel)
+	);
+	webkit_settings_set_auto_load_images(
+	    c->settings, !CFG_B(DisableAutoLoadImages)
+	);
+	webkit_settings_set_default_font_family(
+	    c->settings, CFG_S(DefaultFont)
+	);
+	webkit_settings_set_default_font_size(
+	    c->settings, CFG_I(DefaultFontSize)
+	);
+	webkit_settings_set_enable_developer_extras(
+	    c->settings, CFG_B(DeveloperExtras)
+	);
+	webkit_settings_set_enable_smooth_scrolling(
+	    c->settings, CFG_B(SmoothScrolling)
+	);
+	webkit_settings_set_enable_write_console_messages_to_stdout(
+	    c->settings, CFG_B(ConsoleToStdout)
+	);
+	webkit_settings_set_monospace_font_family(
+	    c->settings, CFG_S(MonospaceFont)
+	);
+	webkit_settings_set_sans_serif_font_family(
+	    c->settings, CFG_S(SansSerifFont)
+	);
+	webkit_settings_set_serif_font_family(
+	    c->settings, CFG_S(SerifFont)
+	);
+
+	/* create entry */
+	c->entry = gtk_entry_new();
+	CB(c->entry, "key-press-event",             cb_entry_hid, c);
+	CB(c->entry, "icon-release",                cb_entry_icon_hid, c);
+	/* entry must exist before first call */
+	set_javascript_policy(c, JSP_ENABLE);
+
+	/* create vertical box to store the web view and the entry */
+	c->vbx = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
+	gtk_box_pack_start(GTK_BOX(c->vbx), c->wv, TRUE, TRUE, 0);
+	gtk_box_pack_start(GTK_BOX(c->vbx), c->entry, FALSE, FALSE, 0);
+	gtk_container_set_focus_child(GTK_CONTAINER(c->vbx), c->wv);
+
+	/* create tab containing an icon and a label */
+	c->tab_icon = gtk_image_new_from_icon_name(ICON_GLOBE, GTK_ICON_SIZE_MENU);
+	c->tab_label = gtk_label_new(__NAME__);
+	gtk_label_set_ellipsize(GTK_LABEL(c->tab_label), PANGO_ELLIPSIZE_END);
+	gtk_widget_set_halign(GTK_WIDGET(c->tab_label), GTK_ALIGN_START);
+	gtk_widget_set_hexpand(GTK_WIDGET(c->tab_label), TRUE);
+	gtk_widget_set_has_tooltip(GTK_WIDGET(c->tab_label), TRUE);
+	/* pack icon and label in a horizontal box */
+	t = gtk_box_new(
+	    GTK_ORIENTATION_HORIZONTAL, 5 * gtk_widget_get_scale_factor(mw.win)
+	);
+	gtk_box_pack_start(GTK_BOX(t), c->tab_icon, FALSE, FALSE, 0);
+	gtk_box_pack_start(
+	    GTK_BOX(t),
+	    c->tab_label,
+	    TRUE,
+	    TRUE,
+	    3 * gtk_widget_get_scale_factor(mw.win)
+	);
+	/* back the tab inside an event box to enable scroll and button events */
+	e = gtk_event_box_new();
+	gtk_container_add(GTK_CONTAINER(e), t);
+	gtk_widget_add_events(e, GDK_SCROLL_MASK);
+	CB(e, "button-release-event",               cb_tab_hid, c);
+	CB(e, "scroll-event",                       cb_tab_hid, c);
+	/* store a (non client) reference to the label for later use */
+	g_object_set_data(G_OBJECT(e), __NAME__"-tab-label", c->tab_label);
+	/* show tab */
+	gtk_widget_show_all(e);
+
+	/* append everything reorderable to the notebook after current page */
+	gtk_notebook_insert_page(
+	    GTK_NOTEBOOK(mw.nb),
+	    c->vbx,
+	    e,
+	    gtk_notebook_get_current_page(GTK_NOTEBOOK(mw.nb)) + 1
+	);
+	gtk_notebook_set_tab_reorderable(GTK_NOTEBOOK(mw.nb), c->vbx, TRUE);
+
+	/* manage which tab should be focused */
+	c->focus_new_tab = focus_tab;
+	if (show)
+		show_web_view(c);
+	else
+		CB(c->wv, "ready-to-show",              cb_wv_show, c);
+
+	/* finally load the uri */
+	if (uri != NULL) {
+		webkit_web_view_load_uri(
+		    WEBKIT_WEB_VIEW(c->wv), (u = resolve_uri(uri))
+		);
+		g_free(u);
+	}
+
+	gl.clients++;
+	return c;
+}
+
+void
+client_destroy(struct Client *c)
+{
+	int                     i;
+
+	/* disconnect all handlers */
+	g_signal_handlers_disconnect_by_data(G_OBJECT(c->wv), c);
+	g_signal_handlers_disconnect_by_data(G_OBJECT(c->wv), NULL);
+
+	if ((i = gtk_notebook_page_num(GTK_NOTEBOOK(mw.nb), c->vbx)) != -1)
+		gtk_notebook_remove_page(GTK_NOTEBOOK(mw.nb), i);
+	else
+		fprintf(stderr, __NAME__": Page does not exist in notebook\n");
+
+	free(c);
+
+	if (--gl.clients == 0)
+		quit();
+}
+
+gboolean
+command(struct Client *c, const gchar* t)
+{
+	if (t[0] == '/') {          /* in-page search */
+		g_free(gl.search_text);
+		gl.search_text = g_strdup(t + 1);
+		search(c, IPS_INIT);
+		return TRUE;
+	} else if (t[0] == 'q') {   /* quit (vim-like) */
+		quit();
+		return TRUE;
+	}
+
+	return FALSE;
+}
+
+void
+create_context_menu(struct Client *c, WebKitContextMenu *context_menu,
+                    WebKitHitTestResult *hit_test_result)
+{
+	GAction                *a;                  /* action: freed when quit */
+	if (webkit_hit_test_result_context_is_link(hit_test_result)) {
+		CB(
+		    (a = (GAction*)g_simple_action_new("open-external", NULL)),
+		    "activate",
+		    cb_open_external,
+		    c
+		);
+		webkit_context_menu_insert(
+		    context_menu,
+		    webkit_context_menu_item_new_from_gaction(
+		        a, "Open link externally", NULL
+		    ),
+		    2
+		);
+	}
+}
+
+void
+die(const char *fmt, ...)
+{
+	va_list                 ap;
+
+	va_start(ap, fmt);
+	vfprintf(stderr, fmt, ap);
+	va_end(ap);
+	exit(EXIT_FAILURE);
+}
+
+gboolean
+ipc_request(GIOChannel *src, GIOCondition condition, gpointer data)
+{
+	gchar                  *u = NULL;           /* uri received */
+
+	(void)condition;        /* not used */
+	(void)data;             /* not used */
+
+	g_io_channel_read_line(src, &u, NULL, NULL, NULL);
+	if (u) {
+		g_strstrip(u);
+		client_create(u, NULL, TRUE, TRUE);
+		g_free(u);
+	}
+	return TRUE;
+}
+
+ssize_t
+ipc_send(char *data)
+{
+	size_t                  s = 0,              /* data amount sent */
+	                        l = strlen(data);   /* data length */
+	ssize_t                 w;                  /* data written */
+
+	while (s < l) { /* write until everything is sent */
+		if ((w = write(gl.ipc_pipe_fd, data + s, l - s)) == -1) {
+			if (errno == EINTR)
+				continue;       /* EINTR: so retry */
+			perror(__NAME__": Error writing to fifo");
+			return w;
+		} else if (w == 0) {
+			return 0;
+		}
+		s += w;
+	}
+
+	return s;
+}
+
+void
+ipc_setup(void)
+{
+	gchar                  *f,                  /* fifo file name */
+	                       *p;                  /* fifo file path */
+
+	/* only setup for ipc clients */
+	if (gl.ipc != IPC_CLIENT)
+		return;
+
+	/* create fifo file path and allow for several ipc setups by naming them */
+	f = g_strdup_printf("%s_%s.fifo", __NAME__, CFG_S(FifoName));
+	p = g_build_filename(g_get_user_runtime_dir(), f, NULL);
+
+	/* fail hard if fifo cannot be created */
+	if (!g_file_test(p, G_FILE_TEST_EXISTS) && mkfifo(p, 0600) == -1)
+		die("%s: fatal: mkfifo failed\n", __NAME__);
+
+	/* if no one is listening create the ipc host instance */
+	if ((gl.ipc_pipe_fd = open(p, O_WRONLY | O_NONBLOCK)) == -1) {
+		g_io_add_watch(
+		    g_io_channel_new_file(p, "r+", NULL),
+		    G_IO_IN,
+		    (GIOFunc)ipc_request,
+		    NULL
+		);
+		gl.ipc = IPC_HOST;  /* convert client to host */
+	}
+
+	g_free(f);
+	g_free(p);
+}
+
+gboolean
+key_common(struct Client *c, GdkEventKey *event)
+{
+	int                     i,
+	                        m;
+	gchar                  *u;
+
+	/* only handle key presses using the alt key */
+	if (!(event->state & GDK_MOD1_MASK))
+		return FALSE;
+
+	/* key presses using ctrl+alt keys */
+	if (event->state & GDK_CONTROL_MASK) {
+		switch (event->keyval) {
+		case GDK_KEY_J:
+		case GDK_KEY_K: /* move page/tab backwards or forwards in stack */
+			i = gtk_notebook_page_num(GTK_NOTEBOOK(mw.nb), c->vbx);
+			m = gtk_notebook_get_n_pages(GTK_NOTEBOOK(mw.nb)) - 1;
+			i += event->keyval == GDK_KEY_J
+			    ? i == 0 ? 0 : -1
+			    : i == m ? m : 1;
+			gtk_notebook_reorder_child(GTK_NOTEBOOK(mw.nb), c->vbx, i);
+			return TRUE;
+		case GDK_KEY_j: /* go to previous page/tab */
+			gtk_notebook_prev_page(GTK_NOTEBOOK(mw.nb));
+			return TRUE;
+		case GDK_KEY_k: /* go to next page/tab */
+			gtk_notebook_next_page(GTK_NOTEBOOK(mw.nb));
+			return TRUE;
+		}
+	}
+
+	switch (event->keyval) {
+	case GDK_KEY_q: /* destroy client and close tab */
+		client_destroy(c);
+		return TRUE;
+	case GDK_KEY_w: /* go to home page */
+		webkit_web_view_load_uri(
+		    WEBKIT_WEB_VIEW(c->wv), (u = resolve_uri(CFG_S(HomeUri)))
+		);
+		g_free(u);
+		return TRUE;
+	case GDK_KEY_t: /* create new client/tab */
+		c = client_create((u = resolve_uri(CFG_S(HomeUri))), NULL, TRUE, TRUE);
+		g_free(u);
+		gtk_widget_grab_focus(c->entry);
+		return TRUE;
+	case GDK_KEY_r: /* reload, while bypassing cache */
+		webkit_web_view_reload_bypass_cache(WEBKIT_WEB_VIEW(c->wv));
+		return TRUE;
+	case GDK_KEY_o: /* focus entry */
+		gtk_widget_grab_focus(c->entry);
+		return TRUE;
+	case GDK_KEY_n: /* search forward */
+		search(c, IPS_FORWARD);
+		return TRUE;
+	case GDK_KEY_N: /* search backward */
+		search(c, IPS_BACKWARD);
+		return TRUE;
+	case GDK_KEY_slash: /* initiate in-page search */
+		gtk_widget_grab_focus(c->entry);
+		gtk_entry_set_text(GTK_ENTRY(c->entry), ":/");
+		gtk_editable_set_position(GTK_EDITABLE(c->entry), -1);
+		return TRUE;
+	case GDK_KEY_b: /* toggle tab visibility */
+		gtk_notebook_set_show_tabs(
+		    GTK_NOTEBOOK(mw.nb),
+		    !gtk_notebook_get_show_tabs(GTK_NOTEBOOK(mw.nb))
+		);
+		return TRUE;
+	case GDK_KEY_1:
+	case GDK_KEY_2:
+	case GDK_KEY_3:
+	case GDK_KEY_4:
+	case GDK_KEY_5:
+	case GDK_KEY_6:
+	case GDK_KEY_7:
+	case GDK_KEY_8:
+	case GDK_KEY_9: /* go to nth tab */
+		gtk_notebook_set_current_page(GTK_NOTEBOOK(mw.nb), event->keyval-0x31);
+		return TRUE;
+	case GDK_KEY_H: /* go back in history */
+		webkit_web_view_go_back(WEBKIT_WEB_VIEW(c->wv));
+		return TRUE;
+	case GDK_KEY_L: /* go forward in history */
+		webkit_web_view_go_forward(WEBKIT_WEB_VIEW(c->wv));
+		return TRUE;
+	case GDK_KEY_s: /* toggle javascript (on or off) */
+		set_javascript_policy(c, JSP_TOGGLE);
+		return TRUE;
+	case GDK_KEY_c: /* toggle tls error policy (ignore or fail) */
+		toggle_tls_error_policy(c);
+		return TRUE;
+	case GDK_KEY_h:
+	case GDK_KEY_j:
+	case GDK_KEY_k:
+	case GDK_KEY_l: /* in-page movement by emulating arrow keys... */
+	case GDK_KEY_g:
+	case GDK_KEY_G: /* ... as well as home and end */
+		event->keyval /* translate key press accordingly */
+		    = event->keyval == GDK_KEY_h ? GDK_KEY_Left
+		    : event->keyval == GDK_KEY_j ? GDK_KEY_Down
+		    : event->keyval == GDK_KEY_k ? GDK_KEY_Up
+		    : event->keyval == GDK_KEY_l ? GDK_KEY_Right
+		    : event->keyval == GDK_KEY_g ? GDK_KEY_Home
+		    : /*                        */ GDK_KEY_End;
+		gtk_propagate_event(GTK_WIDGET(c->wv), (GdkEvent*)event);
+		return TRUE;
+	case GDK_KEY_p: /* open print dialog */
+		webkit_print_operation_run_dialog(
+		    webkit_print_operation_new(WEBKIT_WEB_VIEW(c->wv)),
+		    GTK_WINDOW(mw.win)
+		);
+		return TRUE;
+	}
+	return FALSE;
+}
+
+gboolean
+key_entry(struct Client *c, GdkEventKey *event)
+{
+	const gchar            *t,
+	                       *l;
+	gchar                  *u;
+	int                     p,
+	                        m;
+
+	/* handle key presses using the alt key (takes precedence over common) */
+	if (event->state & GDK_MOD1_MASK) {
+		switch (event->keyval) { /* movements inside entry */
+		case GDK_KEY_l:
+		case GDK_KEY_h:
+			p = gtk_editable_get_position(GTK_EDITABLE(c->entry));
+			m = gtk_entry_get_text_length(GTK_ENTRY(c->entry));
+			p += event->keyval == GDK_KEY_l
+				? m > p ? 1 : 0     /* move right */
+				: 0 < p ? -1 : 0;   /* move left */
+			gtk_editable_set_position(GTK_EDITABLE(c->entry), p);
+			return TRUE;
+		}
+	}
+
+	/* handle common key presses */
+	if (key_common(c, event))
+		return TRUE;
+
+	/* handle any key press (not just using the alt key) */
+	switch (event->keyval) {
+	case GDK_KEY_KP_Enter:
+	case GDK_KEY_Return:
+		gtk_widget_grab_focus(c->wv);
+		if ((t = gtk_entry_get_text(GTK_ENTRY(c->entry))) == NULL)
+			return TRUE;
+		if (t[0] != ':') { /* if not a command */
+			/* store current uri before loading new uri */
+			l = WV_GET_URI(c->wv);
+			webkit_web_view_load_uri(
+			    WEBKIT_WEB_VIEW(c->wv), (u = resolve_uri(t))
+			);
+			g_free(u);
+			/* fix: notify::uri won't be raised if current uri is unchanged */
+			if (g_strcmp0(l, WV_GET_URI(c->wv)) == 0)
+				uri_changed(c);
+			return TRUE;
+		} else if (command(c, t + 1)) { /* if command */
+			return TRUE;
+		} /* FALL THROUGH */
+	case GDK_KEY_Escape:
+		gtk_widget_grab_focus(c->wv);
+		t = WV_GET_URI(c->wv);
+		gtk_entry_set_text(GTK_ENTRY(c->entry), (t == NULL ? __NAME__ : t));
+		gtk_editable_set_position(GTK_EDITABLE(c->entry), -1);
+		return TRUE;
+	}
+	return FALSE;
+}
+
+gboolean
+key_tab(struct Client *c, GdkEvent *event)
+{
+	GdkScrollDirection      d;
+
+	if (event->type == GDK_BUTTON_RELEASE) {
+		if (((GdkEventButton *)event)->button == 2) { /* scroll wheel click */
+			client_destroy(c);
+			return TRUE;
+		}
+	} else if (event->type == GDK_SCROLL) { /* scroll wheel selection */
+		gdk_event_get_scroll_direction(event, &d);
+		if (d == GDK_SCROLL_UP)
+			gtk_notebook_next_page(GTK_NOTEBOOK(mw.nb));
+		else if (d == GDK_SCROLL_DOWN)
+			gtk_notebook_prev_page(GTK_NOTEBOOK(mw.nb));
+		return TRUE;
+	}
+	return FALSE;
+}
+
+gboolean
+key_web_view(struct Client *c, GdkEvent *event)
+{
+	gdouble                 dx,                 /* scroll x-delta */
+	                        dy;                 /* scroll y-delta */
+
+	/* handle common key presses */
+	if (event->type == GDK_KEY_PRESS && key_common(c, (GdkEventKey *)event))
+		return TRUE;
+
+	/* escape key: stop web rendering */
+	if (event->type == GDK_KEY_PRESS
+	    && ((GdkEventKey *)event)->keyval == GDK_KEY_Escape) {
+		webkit_web_view_stop_loading(WEBKIT_WEB_VIEW(c->wv));
+		gtk_entry_set_progress_fraction(GTK_ENTRY(c->entry), 0);
+	/* mouse button events */
+	} else if (event->type == GDK_BUTTON_RELEASE) {
+		switch (((GdkEventButton *)event)->button) {
+		case 2:  /* mouse middle button: open in new tab */
+			if (c->hover_uri != NULL) {
+				client_create(c->hover_uri, NULL, TRUE, FALSE);
+				return TRUE;
+			}
+			break;
+		case 8:  /* mouse button back: go back in history */
+			webkit_web_view_go_back(WEBKIT_WEB_VIEW(c->wv));
+			return TRUE;
+		case 9:  /* mouse button forward: go forward in history */
+			webkit_web_view_go_forward(WEBKIT_WEB_VIEW(c->wv));
+			return TRUE;
+		}
+	/* scroll using alt pressed: zoom in or out */
+	} else if (event->type == GDK_SCROLL
+	           && (((GdkEventScroll *)event)->state & GDK_MOD1_MASK)) {
+		gdk_event_get_scroll_deltas(event, &dx, &dy);
+		webkit_web_view_set_zoom_level(
+		    WEBKIT_WEB_VIEW(c->wv),
+		    dx != 0
+		    ? CFG_F(ZoomLevel)
+		    : webkit_web_view_get_zoom_level(WEBKIT_WEB_VIEW(c->wv)) + -dy*0.1);
+		return TRUE;
+	}
+
+	return FALSE;
+}
+
+void
+load_changed(struct Client *c, WebKitLoadEvent event_type)
+{
+	switch (event_type) {
+	/* when page load starts, reset everything */
+	case WEBKIT_LOAD_STARTED:
+		c->https = FALSE;
+		if (c->error_page)
+			c->error_page = FALSE;
+		else
+			g_clear_object(&c->failed_crt);
+		break;
+	/* when page load is redirected, continue as usual */
+	case WEBKIT_LOAD_REDIRECTED:
+		break;
+	/* when page load is committed, get https and tls state */
+	case WEBKIT_LOAD_COMMITTED:
+		c->https = webkit_web_view_get_tls_info(
+		    WEBKIT_WEB_VIEW(c->wv), &c->crt, &c->tls_error
+		);
+		break;
+	/* when page load is finished, run all user scripts */
+	case WEBKIT_LOAD_FINISHED:
+		load_user_styles(WEBKIT_WEB_VIEW(c->wv));
+		run_user_scripts(WEBKIT_WEB_VIEW(c->wv));
+		break;
+	}
+
+	update_title(c);
+}
+
+void
+load_configuration(void)
+{
+	const gchar            *e;                  /* environment variable name */
+	int                     i;
+
+	/* set global defaults */
+	gl.clients              = 0;                /* client counter */
+	gl.ipc                  = IPC_CLIENT;       /* ipc type */
+	gl.ipc_pipe_fd          = 0;                /* ipc pipe file descriptor */
+	gl.search_text          = NULL;             /* in page search phrase */
+	gl.state_lock           = TRUE;             /* prevents state save */
+
+	/* load default configuration */
+	for (i = 0; i < LastConfig; i++) {
+		if (cfg[i].e && (e = g_getenv(cfg[i].e)) != NULL) {
+			switch (cfg[i].t) {
+			case CFG_INT:       cfg[i].v.i = atoi(e); break;
+			case CFG_FLOAT:     cfg[i].v.f = atof(e); break;
+			case CFG_BOOL:      cfg[i].v.b = TRUE; break;
+			case CFG_STRING:    cfg[i].v.s = g_strdup(e); break;
+			case CFG_LIST:      cfg[i].v.l = g_strsplit(e, ",", -1); break;
+			}
+		}
+	}
+}
+
+void
+load_state(void)
+{
+	char                   *u = NULL;           /* line/uri holder */
+	size_t                  l = URI_MAX;        /* length */
+	FILE                   *fp = NULL;          /* file pointer */
+
+	/* only load states for ipc host */
+	if (CFG_S(StateFile) == NULL || gl.ipc != IPC_HOST)
+		return;
+
+	if ((fp = fopen(CFG_S(StateFile), "r")) == NULL) {
+		perror(__NAME__": Error opening state file");
+		return;
+	}
+
+	if (!(u = (char *)malloc(l * sizeof(char))))
+		die("%s: fatal: malloc failed\n", __NAME__);
+
+	/* load uris into new clients */
+	while (getline(&u, &l, fp) >= 0)
+		client_create(u, NULL, TRUE, TRUE);
+
+	/* select first tab if any */
+	if (gl.clients > 0)
+		gtk_notebook_set_current_page(GTK_NOTEBOOK(mw.nb), 0);
+
+	/* enable state save */
+	gl.state_lock = FALSE;
+
+	fclose(fp);
+	free(u);
+}
+
+void
+load_user_styles(WebKitWebView *web_view)
+{
+	gchar                  *c = NULL,           /* file content */
+	                       *p = NULL,           /* path (file) */
+	                       *b = NULL;           /* base directory (scripts) */
+	const gchar            *e = NULL;           /* directory file entry */
+	GDir                   *s = NULL;           /* user style directory */
+
+	b = g_build_filename(g_get_user_config_dir(), __NAME__, CFG_S(UcDir), NULL);
+	if ((s = g_dir_open(b, 0, NULL)) == NULL) {
+		g_free(b);
+		return;
+	}
+
+	webkit_user_content_manager_remove_all_style_sheets(
+	    webkit_web_view_get_user_content_manager(web_view)
+	);
+
+	while ((e = g_dir_read_name(s)) != NULL) {
+		if (g_str_has_suffix((p = g_build_filename(b, e, NULL)), ".css")
+		    && g_file_get_contents(p, &c, NULL, NULL)) {
+			webkit_user_content_manager_add_style_sheet(
+			    webkit_web_view_get_user_content_manager(web_view),
+			    webkit_user_style_sheet_new(
+			        c,
+			        WEBKIT_USER_CONTENT_INJECT_ALL_FRAMES,
+			        WEBKIT_USER_STYLE_LEVEL_USER,
+			        NULL,
+			        NULL
+			    )
+			);
+			g_free(c);
+		}
+		g_free(p);
+	}
+
+	g_dir_close(s);
+	g_free(b);
+}
+
+void
+main_window_setup(void)
+{
+	GtkWidget              *v;                  /* vertical box */
+
+	/* define window elements */
+	mw.win                  = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+	mw.nb                   = gtk_notebook_new();
+	mw.dbx                  = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
+	v                       = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
+
+	/* window settings */
+	gtk_window_set_default_size(GTK_WINDOW(mw.win), 800, 600);
+	gtk_window_set_title(GTK_WINDOW(mw.win), __NAME__);
+
+	/* notebook settings */
+	gtk_notebook_set_scrollable(GTK_NOTEBOOK(mw.nb), TRUE);
+	gtk_notebook_set_tab_pos(GTK_NOTEBOOK(mw.nb), GTK_POS_TOP);
+
+	/* pack everything in a vertical box */
+	gtk_box_pack_start(GTK_BOX(v), mw.nb, TRUE, TRUE, 0);
+	gtk_box_pack_start(GTK_BOX(v), mw.dbx, FALSE, FALSE, 0);
+	gtk_container_add(GTK_CONTAINER(mw.win), v);
+
+	/* connect signal callbacks */
+	CB(mw.win,              "destroy",          cb_quit, NULL);
+	CB(mw.nb,               "switch-page",      cb_notebook_switch_page, NULL);
+	CB(mw.nb,               "page-added",       cb_notebook_modified, NULL);
+	CB(mw.nb,               "page-removed",     cb_notebook_modified, NULL);
+	CB(mw.nb,               "page-reordered",   cb_notebook_modified, NULL);
+}
+
+void
+open_external(struct Client *c)
+{
+	char                    b[URI_MAX];         /* command line buffer */
+	gchar                  *p = NULL;           /* external handler path */
+	p = g_build_filename(
+	    g_get_user_config_dir(), __NAME__, CFG_S(ExternalHandlerFile), NULL
+	);
+	sprintf(b, "%s %s &", p, gtk_entry_get_text(GTK_ENTRY(c->entry)));
+	g_free(p);
+
+	system(b);
+}
+
+void
+prepare_download(WebKitDownload *d, gchar *suggested_filename)
+{
+	gchar                  *s = g_strdup(suggested_filename),
+	                       *p = NULL,           /* proposed path */
+	                       *f = NULL,           /* final path */
+	                       *u = NULL;           /* uri */
+	GtkWidget              *b;                  /* button */
+	int                     i;
+
+	/* make suggested filename safe, by replacing directory separators */
+	for (i = 0; s[i]; i++)
+		if (s[i] == G_DIR_SEPARATOR)
+			s[i] = '_';
+
+	p = g_build_filename(CFG_S(DownloadDirectory), s, NULL);
+	f = g_strdup(p);
+
+	/* check for a free suffix */
+	for (i = 1; g_file_test(f, G_FILE_TEST_EXISTS) && i < SUFFIX_MAX; i++) {
+		g_free(f);
+		f = g_strdup_printf("%s.%d", p, i);
+	}
+
+	if (i < SUFFIX_MAX) {
+		u = g_filename_to_uri(f, NULL, NULL);
+		webkit_download_set_destination(d, u);
+
+		b = gtk_button_new_with_label(s);
+		gtk_button_set_always_show_image(GTK_BUTTON(b), TRUE);
+		gtk_button_set_image(
+		    GTK_BUTTON(b),
+		    gtk_image_new_from_icon_name(ICON_DOWNLOAD, GTK_ICON_SIZE_BUTTON)
+		);
+		gtk_widget_set_margin_end(b, 1);
+		gtk_box_pack_start(GTK_BOX(mw.dbx), b, FALSE, FALSE, 0);
+		gtk_box_reorder_child(GTK_BOX(mw.dbx), b, 0);
+		gtk_widget_show_all(mw.dbx);
+
+		CB(d, "notify::estimated-progress", cb_download_changed_progress, b);
+		CB(d, "finished", cb_download_finished, b);
+		g_object_ref(d);
+		CB(b, "clicked", cb_download_cancel, d);
+	} else { /* could not find a free suffix under the SUFFIX_MAX limit */
+		fprintf(stderr, __NAME__": Limit reached for filename suffix\n");
+		webkit_download_cancel(d);
+	}
+
+	g_free(p);
+	g_free(s);
+	g_free(f);
+	g_free(u);
+}
+
+void
+quit(void)
+{
+	save_state();
+	gtk_main_quit();
+}
+
+void
+render_tls_error(struct Client *c, gchar *uri, GTlsCertificate *crt,
+                 GTlsCertificateFlags cert_flags)
+{
+	GString                *m;                  /* message (error) */
+	gchar                  *h,                  /* html code */
+	                       *p;                  /* pem block */
+
+	m                       = g_string_new(NULL);
+	c->failed_crt           = g_object_ref(crt);
+	c->tls_error            = cert_flags;
+	c->error_page           = TRUE;
+
+	/* translate all flags to messages */
+	if (c->tls_error & G_TLS_CERTIFICATE_UNKNOWN_CA)
+		g_string_append(m, MSG_TLS_CERTIFICATE_UNKNOWN_CA);
+	if (c->tls_error & G_TLS_CERTIFICATE_BAD_IDENTITY)
+		g_string_append(m, MSG_TLS_CERTIFICATE_BAD_IDENTITY);
+	if (c->tls_error & G_TLS_CERTIFICATE_NOT_ACTIVATED)
+		g_string_append(m, MSG_TLS_CERTIFICATE_NOT_ACTIVATED);
+	if (c->tls_error & G_TLS_CERTIFICATE_EXPIRED)
+		g_string_append(m, MSG_TLS_CERTIFICATE_EXPIRED);
+	if (c->tls_error & G_TLS_CERTIFICATE_REVOKED)
+		g_string_append(m, MSG_TLS_CERTIFICATE_REVOKED);
+	if (c->tls_error & G_TLS_CERTIFICATE_INSECURE)
+		g_string_append(m, MSG_TLS_CERTIFICATE_INSECURE);
+	if (c->tls_error & G_TLS_CERTIFICATE_GENERIC_ERROR)
+		g_string_append(m, MSG_TLS_CERTIFICATE_GENERIC_ERROR);
+
+	/* construct html code and load it */
+	g_object_get(crt, "certificate-pem", &p, NULL);
+	h = g_strdup_printf(TLS_MSG_FORMAT, uri, m->str, p);
+	webkit_web_view_load_alternate_html(WEBKIT_WEB_VIEW(c->wv), h, uri, NULL);
+
+	g_string_free(m, TRUE);
+	g_free(h);
+	g_free(p);
+}
+
+void
+run_user_scripts(WebKitWebView *web_view)
+{
+	gchar                  *c = NULL,           /* file content */
+	                       *p = NULL,           /* path (file) */
+	                       *b = NULL;           /* base directory (scripts) */
+	const gchar            *e = NULL;           /* directory file entry */
+	GDir                   *s = NULL;           /* user script directory */
+
+	b = g_build_filename(g_get_user_config_dir(), __NAME__, CFG_S(UsDir), NULL);
+	if ((s = g_dir_open(b, 0, NULL)) == NULL) {
+		g_free(b);
+		return;
+	}
+
+	while ((e = g_dir_read_name(s)) != NULL) {
+		if (g_str_has_suffix((p = g_build_filename(b, e, NULL)), ".js")
+		    && g_file_get_contents(p, &c, NULL, NULL)) {
+			webkit_web_view_run_javascript(web_view, c, NULL, NULL, NULL);
+			g_free(c);
+		}
+		g_free(p);
+	}
+
+	g_dir_close(s);
+	g_free(b);
+}
+
+void
+save_history(const gchar *t)
+{
+	FILE                   *fp;
+
+	if (CFG_S(HistoryFile) == NULL)
+		return;
+
+	if ((fp = fopen(CFG_S(HistoryFile), "a")) != NULL) {
+		fprintf(fp, "%s\n", t);
+		fclose(fp);
+	} else {
+		perror(__NAME__": Error opening history file");
+	}
+}
+
+void
+save_state(void)
+{
+	GList                  *c;                  /* child (notebook page) */
+	int                     i,
+	                        l;                  /* length (number of tabs) */
+	FILE                   *fp;
+
+	/* only save state for ipc host, when state isn't locked for loading */
+	if (CFG_S(StateFile) == NULL || gl.ipc != IPC_HOST || gl.state_lock)
+		return;
+
+	if ((fp = fopen(CFG_S(StateFile), "w+")) == NULL) {
+		perror(__NAME__": Error opening state file");
+		return;
+	}
+
+	/* save uri from each tab into state file */
+	for (i = 0, l = gtk_notebook_get_n_pages(GTK_NOTEBOOK(mw.nb)); i < l; i++) {
+		c = gtk_container_get_children(
+		    GTK_CONTAINER(gtk_notebook_get_nth_page(GTK_NOTEBOOK(mw.nb), i))
+		);
+		if (strcmp(gtk_widget_get_name((c->data)), "WebKitWebView") == 0)
+			fprintf(fp, "%s\n", WV_GET_URI(c->data));
+	}
+
+	fclose(fp);
+}
+
+void
+search(struct Client *c, enum inpage_search_type type)
+{
+	if (gl.search_text == NULL)
+		return;
+
+	switch (type) {
+	case IPS_INIT:
+		webkit_find_controller_search(
+		    webkit_web_view_get_find_controller(WEBKIT_WEB_VIEW(c->wv)),
+		    gl.search_text,
+		    WEBKIT_FIND_OPTIONS_CASE_INSENSITIVE
+		    | WEBKIT_FIND_OPTIONS_WRAP_AROUND,
+		    G_MAXUINT
+		);
+		break;
+	case IPS_FORWARD:
+		webkit_find_controller_search_next(
+		    webkit_web_view_get_find_controller(WEBKIT_WEB_VIEW(c->wv))
+		);
+		break;
+	case IPS_BACKWARD:
+		webkit_find_controller_search_previous(
+		    webkit_web_view_get_find_controller(WEBKIT_WEB_VIEW(c->wv))
+		);
+		break;
+	}
+}
+
+void
+set_default_web_context(void)
+{
+	gchar                  *p;                  /* web extensions path */
+	WebKitWebContext       *c;                  /* web context */
+
+	/* no context needed for clients */
+	if (gl.ipc == IPC_CLIENT)
+		return;
+
+	c = webkit_web_context_get_default();
+	webkit_web_context_set_process_model(
+	    c, WEBKIT_PROCESS_MODEL_MULTIPLE_SECONDARY_PROCESSES
+	);
+
+	p = g_build_filename(g_get_user_config_dir(), __NAME__, CFG_S(WeDir), NULL);
+#if GTK_CHECK_VERSION(3, 98, 0) /* seems to be fixed in 3.98.0, we'll see */
+	webkit_web_context_set_sandbox_enabled(c, TRUE);
+	webkit_web_context_add_path_to_sandbox(c, p, TRUE);
+#else
+	webkit_web_context_set_web_extensions_directory(c, p);
+#endif
+
+	CB(c, "download-started", cb_download_start, NULL);
+	webkit_web_context_set_favicon_database_directory(c, NULL);
+
+	g_free(p);
+}
+
+void
+set_hover_uri(struct Client *c, WebKitHitTestResult *hit_test_result)
+{
+	const char             *t;                  /* entry text holder */
+
+	g_free(c->hover_uri);
+
+	/* only display hovered links */
+	if (webkit_hit_test_result_context_is_link(hit_test_result)) {
+		t = webkit_hit_test_result_get_link_uri(hit_test_result);
+		c->hover_uri = g_strdup(t);
+	} else {
+		t = WV_GET_URI(c->wv);
+		c->hover_uri = NULL;
+	}
+
+	if (!gtk_widget_is_focus(c->entry))
+		gtk_entry_set_text(GTK_ENTRY(c->entry), t);
+}
+
+void
+set_javascript_policy(struct Client *c, enum javascript_policy policy)
+{
+	webkit_settings_set_enable_javascript(c->settings, policy == JSP_TOGGLE
+	    ? !(webkit_settings_get_enable_javascript(c->settings))
+	    : policy
+	);
+	webkit_web_view_reload_bypass_cache(WEBKIT_WEB_VIEW(c->wv));
+	if ((webkit_settings_get_enable_javascript(c->settings)))
+		gtk_entry_set_icon_from_icon_name(
+		    GTK_ENTRY(c->entry), GTK_ENTRY_ICON_SECONDARY, ICON_JS_ON
+		);
+	else
+		gtk_entry_set_icon_from_icon_name(
+		    GTK_ENTRY(c->entry), GTK_ENTRY_ICON_SECONDARY, ICON_JS_OFF
+		);
+}
+
+void
+set_window_title(gint idx)
+{
+	GtkWidget              *c;                  /* notebook child/page */
+
+	if ((c = gtk_notebook_get_nth_page(GTK_NOTEBOOK(mw.nb), idx)) == NULL)
+		return;
+
+	gtk_window_set_title(GTK_WINDOW(mw.win),
+	    gtk_label_get_text(
+	        GTK_LABEL((GtkWidget *)g_object_get_data(
+	            G_OBJECT(gtk_notebook_get_tab_label(GTK_NOTEBOOK(mw.nb), c)),
+	            __NAME__"-tab-label"
+	        ))
+	    )
+	);
+}
+
+void
+show_web_view(struct Client *c)
+{
+	gint                    idx;
+
+	gtk_widget_show_all(mw.win);
+
+	if (c->focus_new_tab) {
+		if ((idx = gtk_notebook_page_num(GTK_NOTEBOOK(mw.nb), c->vbx)) != -1)
+			gtk_notebook_set_current_page(GTK_NOTEBOOK(mw.nb), idx);
+		gtk_widget_grab_focus(c->wv);
+	}
+}
+
+void
+toggle_tls_error_policy(struct Client *c)
+{
+	webkit_website_data_manager_set_tls_errors_policy(
+	    webkit_web_view_get_website_data_manager(WEBKIT_WEB_VIEW(c->wv)),
+	    !webkit_website_data_manager_get_tls_errors_policy(
+	        webkit_web_view_get_website_data_manager(WEBKIT_WEB_VIEW(c->wv))
+	    )
+	);
+	webkit_web_view_reload(WEBKIT_WEB_VIEW(c->wv));
+}
+
+gchar *
+resolve_uri(const gchar *t)
+{
+	gchar                  *u,                  /* uri to return */
+	                       *l = NULL;           /* temporary string */
+	const gchar            *s;
+
+	/* check if valid scheme, and if so just create a copy of the text */
+	if ((s = g_uri_peek_scheme(t)) && g_strv_contains(CFG_L(UriSchemes), s))
+		u = g_strdup(t);
+	/* if path is local, use the file scheme */
+	else if ((l = realpath(t, NULL)) != NULL)
+		u = g_strdup_printf("file://%s", l);
+	/* else, check if the text can be interpreted as a valid https uri; it's
+	 * not enough to check if uri is valid - check for period and no spaces */
+	else if (strchr(t, '.') && !strchr(t, ' ')
+	         && g_uri_is_valid((l = g_strdup_printf("https://%s", t)), 0, NULL))
+		u = g_strdup(l);
+	/* fallback to web search, using a specified search engine */
+	else
+		u = g_strdup_printf(CFG_S(SearchEngineUriFormat), t);
+
+	g_free(l);
+	return u; /* return a pointer that the caller is responsible for freeing */
+}
+
+void
+update_download_button(WebKitDownload *d, GtkButton *btn, gboolean done)
+{
+	gdouble                 p,                  /* percent completed */
+	                        l;                  /* responce length (bytes) */
+	gchar                  *t,                  /* text holder*/
+	                       *f,                  /* file name */
+	                       *b;                  /* base name */
+
+	if ((f = g_filename_from_uri(webkit_download_get_destination(d), NULL, NULL)
+	    ) == NULL)
+		return; /* should never happen, but just in case... */
+
+	p = webkit_download_get_estimated_progress(d);
+	p = (p > 1 ? 1 : p < 0 ? 0 : p) * 100;
+	l = webkit_uri_response_get_content_length(webkit_download_get_response(d));
+	b = g_path_get_basename(f);
+
+	gtk_button_set_label(btn, !done /* set label based on progress */
+		? (t = g_strdup_printf(" %s (%.0f%% of %.1f MB)", b, p, l / 1e6))
+		: (t = g_strdup_printf(" %s", b))
+	);
+
+	g_free(t);
+	g_free(f);
+	g_free(b);
+}
+
+void
+update_favicon(struct Client *c)
+{
+	cairo_surface_t        *f;  /* favicon */
+	GdkPixbuf              *b,  /* pix buffer */
+	                       *s;  /* pix buffer (scaled) */
+
+	/* set fallback favicon */
+	gtk_image_set_from_icon_name(
+	    GTK_IMAGE(c->tab_icon), ICON_GLOBE, GTK_ICON_SIZE_SMALL_TOOLBAR
+	);
+
+	if ((f = webkit_web_view_get_favicon(WEBKIT_WEB_VIEW(c->wv))) == NULL)
+		return;
+
+	if ((b = gdk_pixbuf_get_from_surface(f, 0, 0,
+	    cairo_image_surface_get_width(f),
+	    cairo_image_surface_get_height(f))) == NULL)
+		return;
+
+	s = gdk_pixbuf_scale_simple(b,
+	    16 * gtk_widget_get_scale_factor(c->tab_icon),
+	    16 * gtk_widget_get_scale_factor(c->tab_icon),
+	    GDK_INTERP_BILINEAR
+	);
+	gtk_image_set_from_pixbuf(GTK_IMAGE(c->tab_icon), s);
+
+	g_object_unref(s);
+	g_object_unref(b);
+}
+
+void
+update_load_progress(struct Client *c)
+{
+	gdouble                 p;
+
+	p = webkit_web_view_get_estimated_load_progress(WEBKIT_WEB_VIEW(c->wv));
+	gtk_entry_set_progress_fraction(GTK_ENTRY(c->entry), (p == 1 ? 0 : p));
+}
+
+void
+update_title(struct Client *c)
+{
+	const gchar            *t,
+	                       *u;
+	gchar                  *m;
+
+	u = WV_GET_URI(c->wv);
+	t = webkit_web_view_get_title(WEBKIT_WEB_VIEW(c->wv));
+
+	/* title priority: title, url, __NAME__ */
+	t = t == NULL || t[0] == 0 ? (u == NULL || u[0] == 0 ? __NAME__ : u) : t;
+
+	/* set label markup and certificate icon based on tls status */
+	if (c->failed_crt
+	    || (c->https && c->tls_error != G_TLS_CERTIFICATE_NO_FLAGS)) {
+		m = g_markup_printf_escaped(CFG_S(BadTlsTabFormat), t);
+		gtk_entry_set_icon_from_icon_name(
+		    GTK_ENTRY(c->entry), GTK_ENTRY_ICON_PRIMARY, ICON_BAD_TLS
+		);
+	} else {
+		m = g_markup_printf_escaped(CFG_S(NormalTabFormat), t);
+		if (c->https)
+			gtk_entry_set_icon_from_icon_name(
+			    GTK_ENTRY(c->entry), GTK_ENTRY_ICON_PRIMARY, ICON_TLS
+			);
+		else
+			gtk_entry_set_icon_from_icon_name(
+			    GTK_ENTRY(c->entry), GTK_ENTRY_ICON_PRIMARY, NULL
+			);
+	}
+
+	gtk_label_set_markup(GTK_LABEL(c->tab_label), m);
+	gtk_widget_set_tooltip_text(c->tab_label, t);
+	set_window_title(gtk_notebook_get_current_page(GTK_NOTEBOOK(mw.nb)));
+	g_free(m);
+}
+
+void
+uri_changed(struct Client *c)
+{
+	const gchar            *t;
+
+	/* make sure to not overwrite the "WEB PROCESS CRASHED" message */
+	if ((t = WV_GET_URI(c->wv)) != NULL && strlen(t) > 0) {
+		gtk_entry_set_text(GTK_ENTRY(c->entry), t);
+		save_history(t);
+		save_state();
+	}
+}
+
+void
+web_view_crashed(struct Client *c)
+{
+	gchar                  *t;
+
+	gtk_entry_set_text(
+	    GTK_ENTRY(c->entry),
+	    (t = g_strdup_printf("WEB PROCESS CRASHED: %s", WV_GET_URI(c->wv)))
+	);
+	g_free(t);
+}
+
+int
+main(int argc, char **argv)
+{
+	int                     opt,
+	                        i;
+
+	gtk_init(&argc, &argv);
+
+	/* load default configuration before reading command-line arguments */
+	load_configuration();
+
+	while ((opt = getopt(argc, argv, "I")) != -1)
+		switch (opt) {
+		case 'I':
+			gl.ipc = IPC_NONE;
+			break;
+		default:
+			die("Usage: %s [OPTION]... [URI]...\n", __NAME__);
+		}
+
+	ipc_setup();
+	set_default_web_context();
+	main_window_setup();
+	load_state();
+
+	/* load a default home uri if no clients or arguments exist  */
+	if (optind >= argc && gl.clients == 0)
+		client_create(CFG_S(HomeUri), NULL, TRUE, TRUE);
+	/* load remaining command line arguments as uris into new clients */
+	else if (optind < argc)
+		for (i = optind; i < argc; i++)
+			client_create(argv[i], NULL, TRUE, TRUE);
+
+	/* don't load gtk for ipc clients, they have done their bit */
+	if (gl.ipc != IPC_CLIENT)
+		gtk_main();
+
+	exit(EXIT_SUCCESS);
+}
diff --git a/browser.h b/browser.h
@@ -0,0 +1,528 @@
+/**
+ * Copyright (C) 2023 Chris Noxz
+ * Author(s): Chris Noxz <chris@noxz.tech>
+ *
+ * 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/>.
+ */
+
+#ifndef BROWSER_H
+#define BROWSER_H
+
+#include <fcntl.h>
+#include <limits.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+
+#include <JavaScriptCore/JavaScript.h>
+#include <gdk/gdkkeysyms.h>
+#include <gio/gio.h>
+#include <gtk/gtk.h>
+#include <gtk/gtkx.h>
+#include <webkit2/webkit2.h>
+
+#define URI_MAX             2000
+#define SUFFIX_MAX          100
+#define ICON_DOWNLOAD       "network-receive-symbolic"
+#define ICON_FINISHED       "emblem-default-symbolic"
+#define ICON_GLOBE          "globe-symbolic"
+#define ICON_TLS            "channel-secure-symbolic"
+#define ICON_BAD_TLS        "channel-insecure-symbolic"
+#define ICON_JS_ON          "emblem-ok-symbolic"
+#define ICON_JS_OFF         "action-unavailable-symbolic"
+#define CB(C, E, F, D)                                                         \
+        {                                                                      \
+            g_signal_connect(G_OBJECT(C), (E), G_CALLBACK(F), (D));            \
+        }
+#define CFG_B(X)            cfg[(X)].v.b
+#define CFG_F(X)            cfg[(X)].v.f
+#define CFG_I(X)            cfg[(X)].v.i
+#define CFG_L(X)            (const gchar* const*)cfg[(X)].v.l
+#define CFG_S(X)            cfg[(X)].v.s
+#define WV_GET_URI(X)       webkit_web_view_get_uri(WEBKIT_WEB_VIEW((X)))
+
+#define TLS_MSG_FORMAT      "<h2>Could not validate TLS for: %s</h2><pre>%s"   \
+                            "</pre><pre>%s</pre>"
+#define MSG_TLS_CERTIFICATE_UNKNOWN_CA                                         \
+                            ">  The signing certificate authority is not known"\
+                            ".<br>"
+#define MSG_TLS_CERTIFICATE_BAD_IDENTITY                                       \
+                            ">  The certificate does not match the expected"   \
+                            "identity of the site that it was retrieved from." \
+                            "<br>"
+#define MSG_TLS_CERTIFICATE_NOT_ACTIVATED                                      \
+                            ">  The certificate's activation time is still in" \
+                            " the future.<br>"
+#define MSG_TLS_CERTIFICATE_EXPIRED                                            \
+                            ">  The certificate has expired.<br>"
+#define MSG_TLS_CERTIFICATE_REVOKED                                            \
+                            ">  The certificate has been revoked according to" \
+                            " the GTlsConnection's certificate revocation list"\
+                            ".<br>"
+#define MSG_TLS_CERTIFICATE_INSECURE                                           \
+                            ">  The certificate's algorithm is considered "    \
+                            "insecure.<br>"
+#define MSG_TLS_CERTIFICATE_GENERIC_ERROR                                      \
+                            ">  Some error occurred validating the certificate"\
+                            ".<br>"
+
+enum javascript_policy {
+	JSP_DISABLE             = 0,
+	JSP_ENABLE              = 1,
+	JSP_TOGGLE              = 2
+};
+
+enum inpage_search_type {
+	IPS_INIT,
+	IPS_FORWARD,
+	IPS_BACKWARD
+};
+
+enum ipc_type {
+	IPC_NONE,
+	IPC_HOST,
+	IPC_CLIENT
+};
+
+enum config_type {
+	CFG_INT,
+	CFG_FLOAT,
+	CFG_BOOL,
+	CFG_STRING,
+	CFG_LIST,
+};
+
+enum config_name {
+	AcceptedLanguages,
+	BadTlsTabFormat,
+	ConsoleToStdout,
+	CookieFile,
+	DefaultFont,
+	DefaultFontSize,
+	DeveloperExtras,
+	DisableAutoLoadImages,
+	DownloadDirectory,
+	ExternalHandlerFile,
+	FifoName,
+	HistoryFile,
+	HomeUri,
+	MonospaceFont,
+	NormalTabFormat,
+	ProxyIgnore,
+	ProxyUri,
+	SansSerifFont,
+	SearchEngineUriFormat,
+	SerifFont,
+	SmoothScrolling,
+	StateFile,
+	UriSchemes,
+	UserAgent,
+	UcDir,      /* user (cascading) style sheets directory */
+	UsDir,      /* user scripts directory */
+	WeDir,      /* web extension directory */
+	ZoomLevel,
+	/* must be last to represent number of config items */
+	LastConfig
+};
+
+typedef union {
+	gint                    i;              /* union integer */
+	gdouble                 f;              /* union float/double */
+	gboolean                b;              /* union boolean */
+	gchar                  *s;              /* union string */
+	gchar                 **l;              /* union string list/array */
+} Arg;
+
+struct Client
+{
+	GTlsCertificate        *crt;            /* last certificate */
+	GtkWidget              *entry;          /* uri/command/entry */
+	gboolean                error_page;     /* flag if error page */
+	GTlsCertificate        *failed_crt;     /* last failed certificate */
+	gboolean                focus_new_tab;  /* flag for focusing tab */
+	gchar                  *hover_uri;      /* uri last hovered */
+	gboolean                https;          /* flag if https site */
+	WebKitSettings         *settings;       /* reference to webkit settings */
+	GtkWidget              *tab_icon;       /* holder for favicon in tab */
+	GtkWidget              *tab_label;      /* holder for title in tab */
+	GTlsCertificateFlags    tls_error;      /* last tls error */
+	GtkWidget              *vbx;            /* vertical box (view + entry) */
+	GtkWidget              *wv;             /* web view */
+};
+
+typedef struct {
+	const char             *e;
+	enum config_type        t;
+	Arg                     v;
+} Config;
+
+struct Global {
+	int                     clients;
+	gboolean                state_lock;
+	enum ipc_type           ipc;
+	int                     ipc_pipe_fd;
+	gchar                  *search_text;
+} gl;
+
+struct MainWindow
+{
+	GtkWidget              *dbx;
+	GtkWidget              *nb;
+	GtkWidget              *win;
+} mw;
+
+/* "normal" functions */
+static struct Client *client_create(const gchar *, WebKitWebView *, gboolean,
+                                    gboolean);
+static void client_destroy(struct Client *);
+static gboolean command(struct Client *, const gchar*);
+static void create_context_menu(struct Client *, WebKitContextMenu *,
+                                WebKitHitTestResult *);
+static void die(const char *, ...);
+static gboolean ipc_request(GIOChannel *, GIOCondition, gpointer);
+static ssize_t ipc_send(char *);
+static void ipc_setup(void);
+static gboolean key_common(struct Client *, GdkEventKey *);
+static gboolean key_entry(struct Client *, GdkEventKey *);
+static gboolean key_tab(struct Client *, GdkEvent *);
+static gboolean key_web_view(struct Client *, GdkEvent *);
+static void load_changed(struct Client *, WebKitLoadEvent);
+static void load_configuration(void);
+static void load_state(void);
+static void load_user_styles(WebKitWebView *);
+static void main_window_setup(void);
+static void open_external(struct Client *);
+static void prepare_download(WebKitDownload *, gchar *);
+static void quit(void);
+static void render_tls_error(struct Client *, gchar *, GTlsCertificate *,
+                             GTlsCertificateFlags);
+static void run_user_scripts(WebKitWebView *);
+static void save_history(const gchar *);
+static void save_state(void);
+static void search(struct Client *, enum inpage_search_type);
+static void set_default_web_context(void);
+static void set_hover_uri(struct Client *, WebKitHitTestResult *);
+static void set_javascript_policy(struct Client *, enum javascript_policy);
+static void set_window_title(gint);
+static void show_web_view(struct Client *);
+static void toggle_tls_error_policy(struct Client *);
+static gchar *resolve_uri(const gchar *);
+static void update_download_button(WebKitDownload *, GtkButton *, gboolean);
+static void update_favicon(struct Client *);
+static void update_load_progress(struct Client *);
+static void update_title(struct Client *);
+static void uri_changed(struct Client *);
+static void web_view_crashed(struct Client *);
+
+/* callback functions */
+static gboolean cb_context_menu(WebKitWebView *, WebKitContextMenu *,
+                                GdkEvent *, WebKitHitTestResult *, gpointer);
+static void cb_download_cancel(GtkWidget *, gpointer);
+static void cb_download_changed_progress(GObject *, GParamSpec *, gpointer);
+static void cb_download_finished(GObject *, gpointer);
+static gboolean cb_download_prepare(WebKitDownload *, gchar *, gpointer);
+static void cb_download_start(WebKitWebView *, WebKitDownload *, gpointer);
+static void cb_favicon_changed(GObject *, GParamSpec *, gpointer);
+static gboolean cb_entry_hid(GtkWidget *, GdkEvent *, gpointer);
+static void cb_entry_icon_hid(GtkEntry *, GtkEntryIconPosition, GdkEvent *,
+                              gpointer);
+static void cb_notebook_modified(GtkNotebook *, GtkWidget *, guint, gpointer);
+static void cb_notebook_switch_page(GtkNotebook *, GtkWidget *, guint,
+                                    gpointer);
+static gboolean cb_open_external(GSimpleAction *, GVariant *, gpointer);
+static void cb_quit(GObject *, gpointer);
+static gboolean cb_tab_hid(GtkWidget *, GdkEvent *, gpointer);
+static void cb_title_changed(GObject *, GParamSpec *, gpointer);
+static void cb_uri_changed(GObject *, GParamSpec *, gpointer);
+static void cb_wv_close(GtkWidget *, gpointer);
+static gboolean cb_wv_crashed(WebKitWebView *, gpointer);
+static WebKitWebView *cb_wv_create(WebKitWebView *, WebKitNavigationAction *,
+                                   gpointer);
+static gboolean cb_wv_decide_policy(WebKitWebView *, WebKitPolicyDecision *,
+                                    WebKitPolicyDecisionType, gpointer);
+static gboolean cb_wv_hid(GtkWidget *, GdkEvent *, gpointer);
+static void cb_wv_hover(WebKitWebView *, WebKitHitTestResult *, guint,
+                        gpointer);
+static void cb_wv_load_changed(GObject *, GParamSpec *, gpointer);
+static void cb_wv_load_progress_changed(GObject *, GParamSpec *, gpointer);
+static void cb_wv_show(WebKitWebView *, gpointer);
+static gboolean cb_wv_tls_load_failed(GObject *, gchar *, GTlsCertificate *,
+                                      GTlsCertificateFlags, gpointer);
+
+
+gboolean
+cb_context_menu(WebKitWebView *web_view, WebKitContextMenu *context_menu,
+                GdkEvent *event, WebKitHitTestResult *hit_test_result,
+                gpointer data)
+{
+	(void)web_view;
+	(void)event;
+
+	create_context_menu((struct Client *)data, context_menu, hit_test_result);
+	return FALSE;
+}
+
+void
+cb_download_cancel(GtkWidget *btn, gpointer data)
+{
+	webkit_download_cancel(WEBKIT_DOWNLOAD(data));
+	g_object_unref(WEBKIT_DOWNLOAD(data));
+	gtk_widget_destroy(btn);
+}
+
+void
+cb_download_changed_progress(GObject *obj, GParamSpec *pspec, gpointer data)
+{
+	(void)pspec;
+
+	update_download_button(WEBKIT_DOWNLOAD(obj), GTK_BUTTON(data), FALSE);
+}
+
+void
+cb_download_finished(GObject *obj, gpointer data)
+{
+	if (!GTK_IS_BUTTON(data))
+		return;
+
+	update_download_button(WEBKIT_DOWNLOAD(obj), GTK_BUTTON(data), TRUE);
+	gtk_button_set_image(
+	    GTK_BUTTON(data),
+	    gtk_image_new_from_icon_name(ICON_FINISHED, GTK_ICON_SIZE_BUTTON)
+	);
+}
+
+gboolean
+cb_download_prepare(WebKitDownload *download, gchar *suggested_filename,
+                    gpointer data)
+{
+	(void)data;
+
+	prepare_download(download, suggested_filename);
+	return FALSE;
+}
+
+void
+cb_download_start(WebKitWebView *web_view, WebKitDownload *download,
+                  gpointer data)
+{
+	(void)web_view;
+
+	CB(download, "decide-destination", cb_download_prepare, data);
+}
+
+void
+cb_favicon_changed(GObject *obj, GParamSpec *pspec, gpointer data)
+{
+	(void)obj;
+	(void)pspec;
+
+	update_favicon((struct Client *)data);
+}
+
+gboolean
+cb_entry_hid(GtkWidget *widget, GdkEvent *event, gpointer data)
+{
+	(void)widget;
+
+	/* only handle key presses */
+	if (event->type == GDK_KEY_PRESS)
+		return key_entry((struct Client *)data, (GdkEventKey*)event);
+
+	return FALSE;
+
+}
+
+void
+cb_entry_icon_hid(GtkEntry *entry, GtkEntryIconPosition icon_pos,
+                  GdkEvent *event, gpointer data)
+{
+	(void)entry;
+	(void)event;
+
+	if (icon_pos == GTK_ENTRY_ICON_PRIMARY) {
+		toggle_tls_error_policy((struct Client *)data);
+	} else if (icon_pos == GTK_ENTRY_ICON_SECONDARY) {
+		set_javascript_policy((struct Client *)data, JSP_TOGGLE);
+	}
+}
+
+void
+cb_notebook_modified(GtkNotebook *notebook, GtkWidget *child, guint idx,
+                     gpointer data)
+{
+	(void)notebook;
+	(void)child;
+	(void)idx;
+	(void)data;
+
+	save_state();
+}
+
+void
+cb_notebook_switch_page(GtkNotebook *notebook, GtkWidget *child, guint idx,
+                        gpointer data)
+{
+	(void)notebook;
+	(void)child;
+	(void)data;
+
+	set_window_title(idx);
+}
+
+gboolean
+cb_open_external(GSimpleAction *action, GVariant *parameter, gpointer data)
+{
+	(void)action;
+	(void)parameter;
+
+	open_external((struct Client *)data);
+	return FALSE;
+}
+
+void
+cb_quit(GObject *obj, gpointer data)
+{
+	(void)obj;
+	(void)data;
+
+	quit();
+}
+
+gboolean
+cb_tab_hid(GtkWidget *widget, GdkEvent *event, gpointer data)
+{
+	(void)widget;
+
+	return key_tab((struct Client *)data, event);
+}
+
+void
+cb_title_changed(GObject *obj, GParamSpec *pspec, gpointer data)
+{
+	(void)obj;
+	(void)pspec;
+
+	update_title((struct Client *)data);
+}
+
+void
+cb_uri_changed(GObject *obj, GParamSpec *pspec, gpointer data)
+{
+	(void)obj;
+	(void)pspec;
+
+	uri_changed((struct Client *)data);
+}
+
+void
+cb_wv_close(GtkWidget *widget, gpointer data)
+{
+	(void)widget;
+
+	client_destroy((struct Client *)data);
+}
+
+gboolean
+cb_wv_crashed(WebKitWebView *web_view, gpointer data)
+{
+	(void)web_view;
+
+	web_view_crashed((struct Client *)data);
+	return TRUE;
+}
+
+WebKitWebView *
+cb_wv_create(WebKitWebView *web_view,
+             WebKitNavigationAction *navigation_action, gpointer data)
+{
+	(void)navigation_action;
+	(void)data;
+
+	return WEBKIT_WEB_VIEW(client_create(NULL, web_view, FALSE, FALSE)->wv);
+}
+
+gboolean
+cb_wv_decide_policy(WebKitWebView *web_view, WebKitPolicyDecision *decision,
+                    WebKitPolicyDecisionType type, gpointer data)
+{
+	(void)web_view;
+	(void)data;
+
+	if (type != WEBKIT_POLICY_DECISION_TYPE_RESPONSE)
+		return FALSE;
+	else if (!webkit_response_policy_decision_is_mime_type_supported(
+	            WEBKIT_RESPONSE_POLICY_DECISION(decision))
+	        )
+		webkit_policy_decision_download(decision);
+	else
+		webkit_policy_decision_use(decision);
+	return TRUE;
+}
+
+gboolean
+cb_wv_hid(GtkWidget *widget, GdkEvent *event, gpointer data)
+{
+	(void)widget;
+
+	return key_web_view((struct Client *)data, event);
+}
+
+void
+cb_wv_hover(WebKitWebView *web_view, WebKitHitTestResult *hit_test_result,
+            guint modifiers, gpointer data)
+{
+	(void)web_view;
+	(void)modifiers;
+
+	set_hover_uri((struct Client *)data, hit_test_result);
+}
+
+void
+cb_wv_load_changed(GObject *obj, GParamSpec *pspec, gpointer data)
+{
+	(void)obj;
+
+	load_changed((struct Client *)data, (WebKitLoadEvent)pspec);
+}
+
+void
+cb_wv_load_progress_changed(GObject *obj, GParamSpec *pspec, gpointer data)
+{
+	(void)obj;
+	(void)pspec;
+
+	update_load_progress((struct Client *)data);
+}
+
+void
+cb_wv_show(WebKitWebView *web_view, gpointer data)
+{
+	(void)web_view;
+
+	show_web_view((struct Client *)data);
+}
+
+gboolean
+cb_wv_tls_load_failed(GObject *obj, gchar *uri, GTlsCertificate *crt,
+                      GTlsCertificateFlags err, gpointer data)
+{
+	(void)obj;
+
+	render_tls_error((struct Client *)data, uri, crt, err);
+	return TRUE;
+}
+
+#endif /* !BROWSER_H */
diff --git a/config.h b/config.h
@@ -0,0 +1,54 @@
+/**
+ * Copyright (C) 2023 Chris Noxz
+ * Author(s): Chris Noxz <chris@noxz.tech>
+ *
+ * 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/>.
+ */
+
+#ifndef CONFIG_H
+#define CONFIG_H
+
+static Config cfg[LastConfig] = {
+	/* config name              enviornment variable name                       config type       default value */
+	[AcceptedLanguages]     = { __NAME_UPPERCASE__"_ACCEPTED_LANGUAGES",        CFG_LIST,   {.l = NULL }},
+	[BadTlsTabFormat]       = { NULL,                                           CFG_STRING, {.s = "<span foreground=\"yellow\" style=\"italic\">%s</span>" }},
+	[ConsoleToStdout]       = { __NAME_UPPERCASE__"_ENABLE_CONSOLE_TO_STDOUT",  CFG_BOOL,   {.b = FALSE }},
+	[CookieFile]            = { __NAME_UPPERCASE__"_COOKIE_FILE",               CFG_STRING, {.s = NULL }},
+	[DefaultFont]           = { __NAME_UPPERCASE__"_DEFAULT_FONT",              CFG_STRING, {.s = "monospace" }},
+	[DefaultFontSize]       = { __NAME_UPPERCASE__"_DEFAULT_FONT_SIZE",         CFG_INT,    {.i = 12 }},
+	[DownloadDirectory]     = { __NAME_UPPERCASE__"_DOWNLOAD_DIR",              CFG_STRING, {.s = "/var/tmp" }},
+	[DeveloperExtras]       = { NULL,                                           CFG_BOOL,   {.b = TRUE }},
+	[ExternalHandlerFile]   = { NULL,                                           CFG_STRING, {.s = "exthandler" }},
+	[FifoName]              = { __NAME_UPPERCASE__"_FIFO_NAME",                 CFG_STRING, {.s = "default" }},
+	[HistoryFile]           = { __NAME_UPPERCASE__"_HISTORY_FILE",              CFG_STRING, {.s = NULL }},
+	[HomeUri]               = { __NAME_UPPERCASE__"_HOME_URI",                  CFG_STRING, {.s = "about:blank" }},
+	[DisableAutoLoadImages] = { __NAME_UPPERCASE__"_DISABLE_AUTO_LOAD_IMAGES",  CFG_BOOL,   {.b = FALSE }},
+	[MonospaceFont]         = { __NAME_UPPERCASE__"_MONOSPACE_FONT",            CFG_STRING, {.s = "monospace" }},
+	[NormalTabFormat]       = { NULL,                                           CFG_STRING, {.s = "<span>%s</span>" }},
+	[ProxyIgnore]           = { __NAME_UPPERCASE__"_PROXY_IGNORE",              CFG_LIST,   {.l = NULL }},
+	[ProxyUri]              = { __NAME_UPPERCASE__"_PROXY_URI",                 CFG_STRING, {.s = NULL }},
+	[SansSerifFont]         = { __NAME_UPPERCASE__"_SANS_SERIF_FONT",           CFG_STRING, {.s = "sans-serif" }},
+	[SearchEngineUriFormat] = { __NAME_UPPERCASE__"_SE_URI_FORMAT",             CFG_STRING, {.s = "https://ddg.gg?q=%s" }},
+	[SerifFont]             = { __NAME_UPPERCASE__"_SERIF_FONT",                CFG_STRING, {.s = "serif" }},
+	[SmoothScrolling]       = { __NAME_UPPERCASE__"_ENABLE_SMOOTH_SCROLLING",   CFG_BOOL,   {.b = FALSE }},
+	[StateFile]             = { __NAME_UPPERCASE__"_STATE_FILE",                CFG_STRING, {.s = NULL }},
+	[UriSchemes]            = { NULL,                                           CFG_LIST,   {.l = (gchar*[]){ "http", "https", "file", "about", "data", "webkit", NULL } }},
+	[UserAgent]             = { __NAME_UPPERCASE__"_USER_AGENT",                CFG_STRING, {.s = NULL }},
+	[UsDir]                 = { NULL,                                           CFG_STRING, {.s = "scripts" }},
+	[UcDir]                 = { NULL,                                           CFG_STRING, {.s = "styles" }},
+	[WeDir]                 = { NULL,                                           CFG_STRING, {.s = "web_extensions" }},
+	[ZoomLevel]             = { __NAME_UPPERCASE__"_ZOOM_LEVEL",                CFG_FLOAT,  {.f = 1.0 }},
+};
+
+#endif /* !CONFIG_H */
diff --git a/config.mk b/config.mk
@@ -0,0 +1,17 @@
+# adji version
+VERSION             = 0.1.9
+
+# adji name
+__NAME__            = adji
+__NAME_UPPERCASE__  = ADJI
+
+# paths
+PREFIX              = /usr/local
+MANPREFIX           = ${PREFIX}/share/man
+
+# flags
+CPPFLAGS            = -DVERSION=\"${VERSION}\" \
+                      -D__NAME__=\"$(__NAME__)\" \
+                      -D__NAME_UPPERCASE__=\"$(__NAME_UPPERCASE__)\" \
+                      -D_DEFAULT_SOURCE
+CFLAGS              = -std=c99 -Wall -Wextra ${CPPFLAGS}
diff --git a/we_redirect.c b/we_redirect.c
@@ -0,0 +1,169 @@
+/**
+ * Copyright (C) 2023 Chris Noxz
+ * Author(s): Chris Noxz <chris@noxz.tech>
+ *
+ * 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/>.
+ */
+
+#include <stdio.h>
+#include <glib.h>
+#include <webkit2/webkit-web-extension.h>
+
+#define     RULE_FILE               "redirect"
+
+GSList      *redirect_patterns      = NULL,
+            *redirect_destinations  = NULL;
+gboolean    verbose                 = FALSE;
+
+
+void
+redirect_load(void)
+{
+	GRegex         *r = NULL;                   /* regex rule */
+	GError         *e = NULL;                   /* errors */
+	GIOChannel     *c = NULL;                   /* reading io channel */
+	gchar          *p = NULL,                   /* path to redirect file */
+	               *l = NULL,                   /* line buffer */
+	                s;                          /* separator holder */
+	int             i,
+	                j,
+	                d;                          /* destination index */
+
+	/* make it possible to debug redirect rules */
+	verbose = g_getenv(__NAME_UPPERCASE__"_VERBOSE") != NULL;
+
+	p = g_build_filename(g_get_user_config_dir(), __NAME__, RULE_FILE, NULL);
+	if ((c = g_io_channel_new_file(p, "r", NULL)) != NULL) {
+		while (g_io_channel_read_line(c, &l, NULL, NULL, NULL)
+		       == G_IO_STATUS_NORMAL) {
+			g_strstrip(l);
+			/* ignore if separator is comment indicator, if not then parse as:
+			   /pattern/replacement/ where '/' can be anything but '#' */
+			if ((s = l[0]) != '#') {
+				for (d = j = i = 0; l[i] && j <= 2; i++) {
+					if (d == 0 && j == 1)
+						d = i;
+					l[i] = l[i + 1];
+					if (l[i] == s) {
+						l[i] = '\0';
+						j++;
+					}
+				}
+
+				if (j == 2) { /* make sure to pass 2 null-terminated strings */
+					r = g_regex_new(
+					    l,
+					    G_REGEX_CASELESS | G_REGEX_OPTIMIZE,
+					    G_REGEX_MATCH_PARTIAL,
+					    &e
+					);
+					if (e != NULL) {
+						fprintf(
+						    stderr,
+						    __NAME__": Could not compile regex: %s\n",
+						    l
+						);
+						g_error_free(e);
+						e = NULL;
+					} else {
+						redirect_patterns = g_slist_append(
+						    redirect_patterns, r
+						);
+						redirect_destinations = g_slist_append(
+						    redirect_destinations, g_strdup(l + d)
+						);
+					}
+				}
+			}
+			g_free(l);
+		}
+		g_io_channel_shutdown(c, FALSE, NULL);
+	}
+	g_free(p);
+}
+
+gboolean
+cb_web_page_send_request(WebKitWebPage *web_page, WebKitURIRequest *request,
+                         WebKitURIResponse *redirected_response, gpointer data)
+{
+	GSList         *p = redirect_patterns,      /* pattern holder */
+	               *d = redirect_destinations;  /* destination holder */
+	const gchar    *i;                          /* incoming uri */
+	gchar          *o = NULL;                   /* outgoing uri */
+
+	(void)web_page;
+	(void)redirected_response;
+	(void)data;
+
+	i = webkit_uri_request_get_uri(request);
+
+	/* go through every rule and apply accordingly */
+	while (p && d) {
+		/* find matching rule for incoming uri */
+		if (g_regex_match((GRegex *)(p->data), i, 0, NULL)) {
+			/* check if destination exists for rule */
+			if (((gchar*)d->data)[0])
+				o = g_regex_replace(
+				    (GRegex *)(p->data),
+				    i,
+				    -1,
+				    0,
+				    ((gchar*)d->data),
+				    G_REGEX_MATCH_DEFAULT,
+				    NULL
+				);
+			if (verbose)
+				fprintf(stderr,
+				    "redirect: %s %s -> %s\n",
+				    g_regex_get_pattern(p->data),
+				    i,
+				    o ? o : "[blocked]"
+				);
+			/* if outgoing uri was constructed, then redirect... */
+			if (o) {
+				webkit_uri_request_set_uri(request, o);
+				g_free(o);
+				return FALSE;
+			/* ...else, block */
+			} else {
+				return TRUE;
+			}
+		}
+		p = g_slist_next(p);
+		d = g_slist_next(d);
+	}
+
+	return FALSE;
+}
+
+void
+cb_web_page_created(WebKitWebExtension *extension, WebKitWebPage *web_page,
+                    gpointer data)
+{
+	(void)extension;
+	(void)data;
+
+	g_signal_connect_object(
+	    web_page, "send-request", G_CALLBACK(cb_web_page_send_request), NULL, 0
+	);
+}
+
+G_MODULE_EXPORT void
+webkit_web_extension_initialize(WebKitWebExtension *extension)
+{
+	redirect_load();
+	g_signal_connect(
+	    extension, "page-created", G_CALLBACK(cb_web_page_created), NULL
+	);
+}