├── .gitattributes ├── .github ├── FUNDING.yml └── workflows │ └── create_release.yaml ├── .gitignore ├── LICENSE ├── Makefile ├── README.md ├── amo-metadata.json ├── docs └── assets │ └── get-the-addon.png └── src ├── .web-extension-id ├── background ├── background.html ├── helpers │ └── localforage.min.js └── index.js ├── content ├── assets │ └── logo.svg ├── deps │ ├── eng-fast.traineddata.gz │ ├── mini-van-0.3.8.min.js │ ├── tesseract-core-simd.js │ ├── tesseract-core-simd.wasm │ ├── tesseract@4.0.5.min.js │ └── worker@4.0.5.min.js ├── index.js ├── page.html ├── page.js └── page │ ├── dom │ ├── editor │ │ ├── editor.js │ │ └── ui.js │ ├── init │ │ ├── init.js │ │ └── ui.js │ └── seo.js │ ├── export │ ├── common │ │ ├── download.js │ │ └── scrubs.js │ ├── html.js │ ├── json.js │ ├── markdown.js │ ├── pdf.js │ └── wtc.js │ ├── ocr │ └── worker.js │ └── tagToName.js ├── icons ├── record.svg └── stop.svg └── manifest.json /.gitattributes: -------------------------------------------------------------------------------- 1 | ## GITATTRIBUTES FOR WEB PROJECTS 2 | # 3 | # These settings are for any web project. 4 | # 5 | # Details per file setting: 6 | # text These files should be normalized (i.e. convert CRLF to LF). 7 | # binary These files are binary and should be left untouched. 8 | # 9 | # Note that binary is a macro for -text -diff. 10 | ###################################################################### 11 | 12 | # Auto detect 13 | ## Handle line endings automatically for files detected as 14 | ## text and leave all files detected as binary untouched. 15 | ## This will handle all files NOT defined below. 16 | * text=auto 17 | 18 | # Source code 19 | *.bash text eol=lf 20 | *.bat text eol=crlf 21 | *.cmd text eol=crlf 22 | *.coffee text 23 | *.css text diff=css 24 | *.htm text diff=html 25 | *.html text diff=html 26 | *.inc text 27 | *.ini text 28 | *.js text 29 | *.json text 30 | *.jsx text 31 | *.less text 32 | *.ls text 33 | *.map text -diff 34 | *.od text 35 | *.onlydata text 36 | *.php text diff=php 37 | *.pl text 38 | *.ps1 text eol=crlf 39 | *.py text diff=python 40 | *.rb text diff=ruby 41 | *.sass text 42 | *.scm text 43 | *.scss text diff=css 44 | *.sh text eol=lf 45 | .husky/* text eol=lf 46 | *.sql text 47 | *.styl text 48 | *.tag text 49 | *.ts text 50 | *.tsx text 51 | *.xml text 52 | *.xhtml text diff=html 53 | 54 | # Docker 55 | Dockerfile text 56 | 57 | # Documentation 58 | *.ipynb text eol=lf 59 | *.markdown text diff=markdown 60 | *.md text diff=markdown 61 | *.mdwn text diff=markdown 62 | *.mdown text diff=markdown 63 | *.mkd text diff=markdown 64 | *.mkdn text diff=markdown 65 | *.mdtxt text 66 | *.mdtext text 67 | *.txt text 68 | AUTHORS text 69 | CHANGELOG text 70 | CHANGES text 71 | CONTRIBUTING text 72 | COPYING text 73 | copyright text 74 | *COPYRIGHT* text 75 | INSTALL text 76 | license text 77 | LICENSE text 78 | NEWS text 79 | readme text 80 | *README* text 81 | TODO text 82 | 83 | # Templates 84 | *.dot text 85 | *.ejs text 86 | *.erb text 87 | *.haml text 88 | *.handlebars text 89 | *.hbs text 90 | *.hbt text 91 | *.jade text 92 | *.latte text 93 | *.mustache text 94 | *.njk text 95 | *.phtml text 96 | *.svelte text 97 | *.tmpl text 98 | *.tpl text 99 | *.twig text 100 | *.vue text 101 | 102 | # Configs 103 | *.cnf text 104 | *.conf text 105 | *.config text 106 | .editorconfig text 107 | .env text 108 | .gitattributes text 109 | .gitconfig text 110 | .htaccess text 111 | *.lock text -diff 112 | package.json text eol=lf 113 | package-lock.json text eol=lf -diff 114 | pnpm-lock.yaml text eol=lf -diff 115 | .prettierrc text 116 | yarn.lock text -diff 117 | *.toml text 118 | *.yaml text 119 | *.yml text 120 | browserslist text 121 | Makefile text 122 | makefile text 123 | 124 | # Heroku 125 | Procfile text 126 | 127 | # Graphics 128 | *.ai binary 129 | *.bmp binary 130 | *.eps binary 131 | *.gif binary 132 | *.gifv binary 133 | *.ico binary 134 | *.jng binary 135 | *.jp2 binary 136 | *.jpg binary 137 | *.jpeg binary 138 | *.jpx binary 139 | *.jxr binary 140 | *.pdf binary 141 | *.png binary 142 | *.psb binary 143 | *.psd binary 144 | # SVG treated as an asset (binary) by default. 145 | *.svg text 146 | # If you want to treat it as binary, 147 | # use the following line instead. 148 | # *.svg binary 149 | *.svgz binary 150 | *.tif binary 151 | *.tiff binary 152 | *.wbmp binary 153 | *.webp binary 154 | 155 | # Audio 156 | *.kar binary 157 | *.m4a binary 158 | *.mid binary 159 | *.midi binary 160 | *.mp3 binary 161 | *.ogg binary 162 | *.ra binary 163 | 164 | # Video 165 | *.3gpp binary 166 | *.3gp binary 167 | *.as binary 168 | *.asf binary 169 | *.asx binary 170 | *.avi binary 171 | *.fla binary 172 | *.flv binary 173 | *.m4v binary 174 | *.mng binary 175 | *.mov binary 176 | *.mp4 binary 177 | *.mpeg binary 178 | *.mpg binary 179 | *.ogv binary 180 | *.swc binary 181 | *.swf binary 182 | *.webm binary 183 | 184 | # Archives 185 | *.7z binary 186 | *.gz binary 187 | *.jar binary 188 | *.rar binary 189 | *.tar binary 190 | *.zip binary 191 | 192 | # Fonts 193 | *.ttf binary 194 | *.eot binary 195 | *.otf binary 196 | *.woff binary 197 | *.woff2 binary 198 | 199 | # Executables 200 | *.exe binary 201 | *.pyc binary 202 | 203 | # RC files (like .babelrc or .eslintrc) 204 | *.*rc text 205 | 206 | # Ignore files (like .npmignore or .gitignore) 207 | *.*ignore text 208 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] 4 | patreon: # Replace with a single Patreon username 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: wrbl606 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry 12 | polar: # Replace with a single Polar username 13 | buy_me_a_coffee: # Replace with a single Buy Me a Coffee username 14 | thanks_dev: # Replace with a single thanks.dev username 15 | custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] 16 | -------------------------------------------------------------------------------- /.github/workflows/create_release.yaml: -------------------------------------------------------------------------------- 1 | name: Create release 2 | 3 | on: 4 | push: 5 | tags: 6 | - 'v*' 7 | 8 | permissions: 9 | contents: write 10 | 11 | jobs: 12 | create-release: 13 | runs-on: ubuntu-latest 14 | steps: 15 | - uses: actions/setup-node@v4 16 | with: 17 | node-version: lts/* 18 | - run: npm install --global web-ext 19 | - uses: actions/checkout@v4 20 | - run: make build 21 | - name: Release 22 | uses: softprops/action-gh-release@v2 23 | with: 24 | files: | 25 | web-ext-artifacts/build.tar.gz 26 | web-ext-artifacts/build.zip 27 | - name: Publish 28 | env: 29 | ADDONS_MOZ_JWT_ISSUER: ${{ secrets.ADDONS_MOZ_JWT_ISSUER }} 30 | ADDONS_MOZ_JWT_SECRET: ${{ secrets.ADDONS_MOZ_JWT_SECRET }} 31 | run: make publish 32 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | web-ext-artifacts/ 3 | node_modules/ 4 | build.tar.gz 5 | .amo-upload-uuid -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | # GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 [Free Software Foundation, Inc.](http://fsf.org/) 5 | 6 | Everyone is permitted to copy and distribute verbatim copies of this license 7 | document, but changing it is not allowed. 8 | 9 | ## Preamble 10 | 11 | The GNU General Public License is a free, copyleft license for software and 12 | other kinds of works. 13 | 14 | The licenses for most software and other practical works are designed to take 15 | away your freedom to share and change the works. By contrast, the GNU General 16 | Public License is intended to guarantee your freedom to share and change all 17 | versions of a program--to make sure it remains free software for all its users. 18 | We, the Free Software Foundation, use the GNU General Public License for most 19 | of our software; it applies also to any other work released this way by its 20 | authors. You can apply it to your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not price. Our 23 | General Public Licenses are designed to make sure that you have the freedom to 24 | distribute copies of free software (and charge for them if you wish), that you 25 | receive source code or can get it if you want it, that you can change the 26 | software or use pieces of it in new free programs, and that you know you can do 27 | these things. 28 | 29 | To protect your rights, we need to prevent others from denying you these rights 30 | or asking you to surrender the rights. Therefore, you have certain 31 | responsibilities if you distribute copies of the software, or if you modify it: 32 | responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether gratis or for 35 | a fee, you must pass on to the recipients the same freedoms that you received. 36 | You must make sure that they, too, receive or can get the source code. And you 37 | must show them these terms so they know their rights. 38 | 39 | Developers that use the GNU GPL protect your rights with two steps: 40 | 41 | 1. assert copyright on the software, and 42 | 2. offer you this License giving you legal permission to copy, distribute 43 | and/or modify it. 44 | 45 | For the developers' and authors' protection, the GPL clearly explains that 46 | there is no warranty for this free software. For both users' and authors' sake, 47 | the GPL requires that modified versions be marked as changed, so that their 48 | problems will not be attributed erroneously to authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run modified 51 | versions of the software inside them, although the manufacturer can do so. This 52 | is fundamentally incompatible with the aim of protecting users' freedom to 53 | change the software. The systematic pattern of such abuse occurs in the area of 54 | products for individuals to use, which is precisely where it is most 55 | unacceptable. Therefore, we have designed this version of the GPL to prohibit 56 | the practice for those products. If such problems arise substantially in other 57 | domains, we stand ready to extend this provision to those domains in future 58 | versions of the GPL, as needed to protect the freedom of users. 59 | 60 | Finally, every program is threatened constantly by software patents. States 61 | should not allow patents to restrict development and use of software on 62 | general-purpose computers, but in those that do, we wish to avoid the special 63 | danger that patents applied to a free program could make it effectively 64 | proprietary. To prevent this, the GPL assures that patents cannot be used to 65 | render the program non-free. 66 | 67 | The precise terms and conditions for copying, distribution and modification 68 | follow. 69 | 70 | ## TERMS AND CONDITIONS 71 | 72 | ### 0. Definitions. 73 | 74 | *This License* refers to version 3 of the GNU General Public License. 75 | 76 | *Copyright* also means copyright-like laws that apply to other kinds of works, 77 | such as semiconductor masks. 78 | 79 | *The Program* refers to any copyrightable work licensed under this License. 80 | Each licensee is addressed as *you*. *Licensees* and *recipients* may be 81 | individuals or organizations. 82 | 83 | To *modify* a work means to copy from or adapt all or part of the work in a 84 | fashion requiring copyright permission, other than the making of an exact copy. 85 | The resulting work is called a *modified version* of the earlier work or a work 86 | *based on* the earlier work. 87 | 88 | A *covered work* means either the unmodified Program or a work based on the 89 | Program. 90 | 91 | To *propagate* a work means to do anything with it that, without permission, 92 | would make you directly or secondarily liable for infringement under applicable 93 | copyright law, except executing it on a computer or modifying a private copy. 94 | Propagation includes copying, distribution (with or without modification), 95 | making available to the public, and in some countries other activities as well. 96 | 97 | To *convey* a work means any kind of propagation that enables other parties to 98 | make or receive copies. Mere interaction with a user through a computer 99 | network, with no transfer of a copy, is not conveying. 100 | 101 | An interactive user interface displays *Appropriate Legal Notices* to the 102 | extent that it includes a convenient and prominently visible feature that 103 | 104 | 1. displays an appropriate copyright notice, and 105 | 2. tells the user that there is no warranty for the work (except to the 106 | extent that warranties are provided), that licensees may convey the work 107 | under this License, and how to view a copy of this License. 108 | 109 | If the interface presents a list of user commands or options, such as a menu, a 110 | prominent item in the list meets this criterion. 111 | 112 | ### 1. Source Code. 113 | 114 | The *source code* for a work means the preferred form of the work for making 115 | modifications to it. *Object code* means any non-source form of a work. 116 | 117 | A *Standard Interface* means an interface that either is an official standard 118 | defined by a recognized standards body, or, in the case of interfaces specified 119 | for a particular programming language, one that is widely used among developers 120 | working in that language. 121 | 122 | The *System Libraries* of an executable work include anything, other than the 123 | work as a whole, that (a) is included in the normal form of packaging a Major 124 | Component, but which is not part of that Major Component, and (b) serves only 125 | to enable use of the work with that Major Component, or to implement a Standard 126 | Interface for which an implementation is available to the public in source code 127 | form. A *Major Component*, in this context, means a major essential component 128 | (kernel, window system, and so on) of the specific operating system (if any) on 129 | which the executable work runs, or a compiler used to produce the work, or an 130 | object code interpreter used to run it. 131 | 132 | The *Corresponding Source* for a work in object code form means all the source 133 | code needed to generate, install, and (for an executable work) run the object 134 | code and to modify the work, including scripts to control those activities. 135 | However, it does not include the work's System Libraries, or general-purpose 136 | tools or generally available free programs which are used unmodified in 137 | performing those activities but which are not part of the work. For example, 138 | Corresponding Source includes interface definition files associated with source 139 | files for the work, and the source code for shared libraries and dynamically 140 | linked subprograms that the work is specifically designed to require, such as 141 | by intimate data communication or control flow between those subprograms and 142 | other parts of the work. 143 | 144 | The Corresponding Source need not include anything that users can regenerate 145 | automatically from other parts of the Corresponding Source. 146 | 147 | The Corresponding Source for a work in source code form is that same work. 148 | 149 | ### 2. Basic Permissions. 150 | 151 | All rights granted under this License are granted for the term of copyright on 152 | the Program, and are irrevocable provided the stated conditions are met. This 153 | License explicitly affirms your unlimited permission to run the unmodified 154 | Program. The output from running a covered work is covered by this License only 155 | if the output, given its content, constitutes a covered work. This License 156 | acknowledges your rights of fair use or other equivalent, as provided by 157 | copyright law. 158 | 159 | You may make, run and propagate covered works that you do not convey, without 160 | conditions so long as your license otherwise remains in force. You may convey 161 | covered works to others for the sole purpose of having them make modifications 162 | exclusively for you, or provide you with facilities for running those works, 163 | provided that you comply with the terms of this License in conveying all 164 | material for which you do not control copyright. Those thus making or running 165 | the covered works for you must do so exclusively on your behalf, under your 166 | direction and control, on terms that prohibit them from making any copies of 167 | your copyrighted material outside their relationship with you. 168 | 169 | Conveying under any other circumstances is permitted solely under the 170 | conditions stated below. Sublicensing is not allowed; section 10 makes it 171 | unnecessary. 172 | 173 | ### 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 174 | 175 | No covered work shall be deemed part of an effective technological measure 176 | under any applicable law fulfilling obligations under article 11 of the WIPO 177 | copyright treaty adopted on 20 December 1996, or similar laws prohibiting or 178 | restricting circumvention of such measures. 179 | 180 | When you convey a covered work, you waive any legal power to forbid 181 | circumvention of technological measures to the extent such circumvention is 182 | effected by exercising rights under this License with respect to the covered 183 | work, and you disclaim any intention to limit operation or modification of the 184 | work as a means of enforcing, against the work's users, your or third parties' 185 | legal rights to forbid circumvention of technological measures. 186 | 187 | ### 4. Conveying Verbatim Copies. 188 | 189 | You may convey verbatim copies of the Program's source code as you receive it, 190 | in any medium, provided that you conspicuously and appropriately publish on 191 | each copy an appropriate copyright notice; keep intact all notices stating that 192 | this License and any non-permissive terms added in accord with section 7 apply 193 | to the code; keep intact all notices of the absence of any warranty; and give 194 | all recipients a copy of this License along with the Program. 195 | 196 | You may charge any price or no price for each copy that you convey, and you may 197 | offer support or warranty protection for a fee. 198 | 199 | ### 5. Conveying Modified Source Versions. 200 | 201 | You may convey a work based on the Program, or the modifications to produce it 202 | from the Program, in the form of source code under the terms of section 4, 203 | provided that you also meet all of these conditions: 204 | 205 | - a) The work must carry prominent notices stating that you modified it, and 206 | giving a relevant date. 207 | - b) The work must carry prominent notices stating that it is released under 208 | this License and any conditions added under section 7. This requirement 209 | modifies the requirement in section 4 to *keep intact all notices*. 210 | - c) You must license the entire work, as a whole, under this License to 211 | anyone who comes into possession of a copy. This License will therefore 212 | apply, along with any applicable section 7 additional terms, to the whole 213 | of the work, and all its parts, regardless of how they are packaged. This 214 | License gives no permission to license the work in any other way, but it 215 | does not invalidate such permission if you have separately received it. 216 | - d) If the work has interactive user interfaces, each must display 217 | Appropriate Legal Notices; however, if the Program has interactive 218 | interfaces that do not display Appropriate Legal Notices, your work need 219 | not make them do so. 220 | 221 | A compilation of a covered work with other separate and independent works, 222 | which are not by their nature extensions of the covered work, and which are not 223 | combined with it such as to form a larger program, in or on a volume of a 224 | storage or distribution medium, is called an *aggregate* if the compilation and 225 | its resulting copyright are not used to limit the access or legal rights of the 226 | compilation's users beyond what the individual works permit. Inclusion of a 227 | covered work in an aggregate does not cause this License to apply to the other 228 | parts of the aggregate. 229 | 230 | ### 6. Conveying Non-Source Forms. 231 | 232 | You may convey a covered work in object code form under the terms of sections 4 233 | and 5, provided that you also convey the machine-readable Corresponding Source 234 | under the terms of this License, in one of these ways: 235 | 236 | - a) Convey the object code in, or embodied in, a physical product (including 237 | a physical distribution medium), accompanied by the Corresponding Source 238 | fixed on a durable physical medium customarily used for software 239 | interchange. 240 | - b) Convey the object code in, or embodied in, a physical product (including 241 | a physical distribution medium), accompanied by a written offer, valid for 242 | at least three years and valid for as long as you offer spare parts or 243 | customer support for that product model, to give anyone who possesses the 244 | object code either 245 | 1. a copy of the Corresponding Source for all the software in the product 246 | that is covered by this License, on a durable physical medium 247 | customarily used for software interchange, for a price no more than your 248 | reasonable cost of physically performing this conveying of source, or 249 | 2. access to copy the Corresponding Source from a network server at no 250 | charge. 251 | - c) Convey individual copies of the object code with a copy of the written 252 | offer to provide the Corresponding Source. This alternative is allowed only 253 | occasionally and noncommercially, and only if you received the object code 254 | with such an offer, in accord with subsection 6b. 255 | - d) Convey the object code by offering access from a designated place 256 | (gratis or for a charge), and offer equivalent access to the Corresponding 257 | Source in the same way through the same place at no further charge. You 258 | need not require recipients to copy the Corresponding Source along with the 259 | object code. If the place to copy the object code is a network server, the 260 | Corresponding Source may be on a different server operated by you or a 261 | third party) that supports equivalent copying facilities, provided you 262 | maintain clear directions next to the object code saying where to find the 263 | Corresponding Source. Regardless of what server hosts the Corresponding 264 | Source, you remain obligated to ensure that it is available for as long as 265 | needed to satisfy these requirements. 266 | - e) Convey the object code using peer-to-peer transmission, provided you 267 | inform other peers where the object code and Corresponding Source of the 268 | work are being offered to the general public at no charge under subsection 269 | 6d. 270 | 271 | A separable portion of the object code, whose source code is excluded from the 272 | Corresponding Source as a System Library, need not be included in conveying the 273 | object code work. 274 | 275 | A *User Product* is either 276 | 277 | 1. a *consumer product*, which means any tangible personal property which is 278 | normally used for personal, family, or household purposes, or 279 | 2. anything designed or sold for incorporation into a dwelling. 280 | 281 | In determining whether a product is a consumer product, doubtful cases shall be 282 | resolved in favor of coverage. For a particular product received by a 283 | particular user, *normally used* refers to a typical or common use of that 284 | class of product, regardless of the status of the particular user or of the way 285 | in which the particular user actually uses, or expects or is expected to use, 286 | the product. A product is a consumer product regardless of whether the product 287 | has substantial commercial, industrial or non-consumer uses, unless such uses 288 | represent the only significant mode of use of the product. 289 | 290 | *Installation Information* for a User Product means any methods, procedures, 291 | authorization keys, or other information required to install and execute 292 | modified versions of a covered work in that User Product from a modified 293 | version of its Corresponding Source. The information must suffice to ensure 294 | that the continued functioning of the modified object code is in no case 295 | prevented or interfered with solely because modification has been made. 296 | 297 | If you convey an object code work under this section in, or with, or 298 | specifically for use in, a User Product, and the conveying occurs as part of a 299 | transaction in which the right of possession and use of the User Product is 300 | transferred to the recipient in perpetuity or for a fixed term (regardless of 301 | how the transaction is characterized), the Corresponding Source conveyed under 302 | this section must be accompanied by the Installation Information. But this 303 | requirement does not apply if neither you nor any third party retains the 304 | ability to install modified object code on the User Product (for example, the 305 | work has been installed in ROM). 306 | 307 | The requirement to provide Installation Information does not include a 308 | requirement to continue to provide support service, warranty, or updates for a 309 | work that has been modified or installed by the recipient, or for the User 310 | Product in which it has been modified or installed. Access to a network may be 311 | denied when the modification itself materially and adversely affects the 312 | operation of the network or violates the rules and protocols for communication 313 | across the network. 314 | 315 | Corresponding Source conveyed, and Installation Information provided, in accord 316 | with this section must be in a format that is publicly documented (and with an 317 | implementation available to the public in source code form), and must require 318 | no special password or key for unpacking, reading or copying. 319 | 320 | ### 7. Additional Terms. 321 | 322 | *Additional permissions* are terms that supplement the terms of this License by 323 | making exceptions from one or more of its conditions. Additional permissions 324 | that are applicable to the entire Program shall be treated as though they were 325 | included in this License, to the extent that they are valid under applicable 326 | law. If additional permissions apply only to part of the Program, that part may 327 | be used separately under those permissions, but the entire Program remains 328 | governed by this License without regard to the additional permissions. 329 | 330 | When you convey a copy of a covered work, you may at your option remove any 331 | additional permissions from that copy, or from any part of it. (Additional 332 | permissions may be written to require their own removal in certain cases when 333 | you modify the work.) You may place additional permissions on material, added 334 | by you to a covered work, for which you have or can give appropriate copyright 335 | permission. 336 | 337 | Notwithstanding any other provision of this License, for material you add to a 338 | covered work, you may (if authorized by the copyright holders of that material) 339 | supplement the terms of this License with terms: 340 | 341 | - a) Disclaiming warranty or limiting liability differently from the terms of 342 | sections 15 and 16 of this License; or 343 | - b) Requiring preservation of specified reasonable legal notices or author 344 | attributions in that material or in the Appropriate Legal Notices displayed 345 | by works containing it; or 346 | - c) Prohibiting misrepresentation of the origin of that material, or 347 | requiring that modified versions of such material be marked in reasonable 348 | ways as different from the original version; or 349 | - d) Limiting the use for publicity purposes of names of licensors or authors 350 | of the material; or 351 | - e) Declining to grant rights under trademark law for use of some trade 352 | names, trademarks, or service marks; or 353 | - f) Requiring indemnification of licensors and authors of that material by 354 | anyone who conveys the material (or modified versions of it) with 355 | contractual assumptions of liability to the recipient, for any liability 356 | that these contractual assumptions directly impose on those licensors and 357 | authors. 358 | 359 | All other non-permissive additional terms are considered *further restrictions* 360 | within the meaning of section 10. If the Program as you received it, or any 361 | part of it, contains a notice stating that it is governed by this License along 362 | with a term that is a further restriction, you may remove that term. If a 363 | license document contains a further restriction but permits relicensing or 364 | conveying under this License, you may add to a covered work material governed 365 | by the terms of that license document, provided that the further restriction 366 | does not survive such relicensing or conveying. 367 | 368 | If you add terms to a covered work in accord with this section, you must place, 369 | in the relevant source files, a statement of the additional terms that apply to 370 | those files, or a notice indicating where to find the applicable terms. 371 | 372 | Additional terms, permissive or non-permissive, may be stated in the form of a 373 | separately written license, or stated as exceptions; the above requirements 374 | apply either way. 375 | 376 | ### 8. Termination. 377 | 378 | You may not propagate or modify a covered work except as expressly provided 379 | under this License. Any attempt otherwise to propagate or modify it is void, 380 | and will automatically terminate your rights under this License (including any 381 | patent licenses granted under the third paragraph of section 11). 382 | 383 | However, if you cease all violation of this License, then your license from a 384 | particular copyright holder is reinstated 385 | 386 | - a) provisionally, unless and until the copyright holder explicitly and 387 | finally terminates your license, and 388 | - b) permanently, if the copyright holder fails to notify you of the 389 | violation by some reasonable means prior to 60 days after the cessation. 390 | 391 | Moreover, your license from a particular copyright holder is reinstated 392 | permanently if the copyright holder notifies you of the violation by some 393 | reasonable means, this is the first time you have received notice of violation 394 | of this License (for any work) from that copyright holder, and you cure the 395 | violation prior to 30 days after your receipt of the notice. 396 | 397 | Termination of your rights under this section does not terminate the licenses 398 | of parties who have received copies or rights from you under this License. If 399 | your rights have been terminated and not permanently reinstated, you do not 400 | qualify to receive new licenses for the same material under section 10. 401 | 402 | ### 9. Acceptance Not Required for Having Copies. 403 | 404 | You are not required to accept this License in order to receive or run a copy 405 | of the Program. Ancillary propagation of a covered work occurring solely as a 406 | consequence of using peer-to-peer transmission to receive a copy likewise does 407 | not require acceptance. However, nothing other than this License grants you 408 | permission to propagate or modify any covered work. These actions infringe 409 | copyright if you do not accept this License. Therefore, by modifying or 410 | propagating a covered work, you indicate your acceptance of this License to do 411 | so. 412 | 413 | ### 10. Automatic Licensing of Downstream Recipients. 414 | 415 | Each time you convey a covered work, the recipient automatically receives a 416 | license from the original licensors, to run, modify and propagate that work, 417 | subject to this License. You are not responsible for enforcing compliance by 418 | third parties with this License. 419 | 420 | An *entity transaction* is a transaction transferring control of an 421 | organization, or substantially all assets of one, or subdividing an 422 | organization, or merging organizations. If propagation of a covered work 423 | results from an entity transaction, each party to that transaction who receives 424 | a copy of the work also receives whatever licenses to the work the party's 425 | predecessor in interest had or could give under the previous paragraph, plus a 426 | right to possession of the Corresponding Source of the work from the 427 | predecessor in interest, if the predecessor has it or can get it with 428 | reasonable efforts. 429 | 430 | You may not impose any further restrictions on the exercise of the rights 431 | granted or affirmed under this License. For example, you may not impose a 432 | license fee, royalty, or other charge for exercise of rights granted under this 433 | License, and you may not initiate litigation (including a cross-claim or 434 | counterclaim in a lawsuit) alleging that any patent claim is infringed by 435 | making, using, selling, offering for sale, or importing the Program or any 436 | portion of it. 437 | 438 | ### 11. Patents. 439 | 440 | A *contributor* is a copyright holder who authorizes use under this License of 441 | the Program or a work on which the Program is based. The work thus licensed is 442 | called the contributor's *contributor version*. 443 | 444 | A contributor's *essential patent claims* are all patent claims owned or 445 | controlled by the contributor, whether already acquired or hereafter acquired, 446 | that would be infringed by some manner, permitted by this License, of making, 447 | using, or selling its contributor version, but do not include claims that would 448 | be infringed only as a consequence of further modification of the contributor 449 | version. For purposes of this definition, *control* includes the right to grant 450 | patent sublicenses in a manner consistent with the requirements of this 451 | License. 452 | 453 | Each contributor grants you a non-exclusive, worldwide, royalty-free patent 454 | license under the contributor's essential patent claims, to make, use, sell, 455 | offer for sale, import and otherwise run, modify and propagate the contents of 456 | its contributor version. 457 | 458 | In the following three paragraphs, a *patent license* is any express agreement 459 | or commitment, however denominated, not to enforce a patent (such as an express 460 | permission to practice a patent or covenant not to sue for patent 461 | infringement). To *grant* such a patent license to a party means to make such 462 | an agreement or commitment not to enforce a patent against the party. 463 | 464 | If you convey a covered work, knowingly relying on a patent license, and the 465 | Corresponding Source of the work is not available for anyone to copy, free of 466 | charge and under the terms of this License, through a publicly available 467 | network server or other readily accessible means, then you must either 468 | 469 | 1. cause the Corresponding Source to be so available, or 470 | 2. arrange to deprive yourself of the benefit of the patent license for this 471 | particular work, or 472 | 3. arrange, in a manner consistent with the requirements of this License, to 473 | extend the patent license to downstream recipients. 474 | 475 | *Knowingly relying* means you have actual knowledge that, but for the patent 476 | license, your conveying the covered work in a country, or your recipient's use 477 | of the covered work in a country, would infringe one or more identifiable 478 | patents in that country that you have reason to believe are valid. 479 | 480 | If, pursuant to or in connection with a single transaction or arrangement, you 481 | convey, or propagate by procuring conveyance of, a covered work, and grant a 482 | patent license to some of the parties receiving the covered work authorizing 483 | them to use, propagate, modify or convey a specific copy of the covered work, 484 | then the patent license you grant is automatically extended to all recipients 485 | of the covered work and works based on it. 486 | 487 | A patent license is *discriminatory* if it does not include within the scope of 488 | its coverage, prohibits the exercise of, or is conditioned on the non-exercise 489 | of one or more of the rights that are specifically granted under this License. 490 | You may not convey a covered work if you are a party to an arrangement with a 491 | third party that is in the business of distributing software, under which you 492 | make payment to the third party based on the extent of your activity of 493 | conveying the work, and under which the third party grants, to any of the 494 | parties who would receive the covered work from you, a discriminatory patent 495 | license 496 | 497 | - a) in connection with copies of the covered work conveyed by you (or copies 498 | made from those copies), or 499 | - b) primarily for and in connection with specific products or compilations 500 | that contain the covered work, unless you entered into that arrangement, or 501 | that patent license was granted, prior to 28 March 2007. 502 | 503 | Nothing in this License shall be construed as excluding or limiting any implied 504 | license or other defenses to infringement that may otherwise be available to 505 | you under applicable patent law. 506 | 507 | ### 12. No Surrender of Others' Freedom. 508 | 509 | If conditions are imposed on you (whether by court order, agreement or 510 | otherwise) that contradict the conditions of this License, they do not excuse 511 | you from the conditions of this License. If you cannot convey a covered work so 512 | as to satisfy simultaneously your obligations under this License and any other 513 | pertinent obligations, then as a consequence you may not convey it at all. For 514 | example, if you agree to terms that obligate you to collect a royalty for 515 | further conveying from those to whom you convey the Program, the only way you 516 | could satisfy both those terms and this License would be to refrain entirely 517 | from conveying the Program. 518 | 519 | ### 13. Use with the GNU Affero General Public License. 520 | 521 | Notwithstanding any other provision of this License, you have permission to 522 | link or combine any covered work with a work licensed under version 3 of the 523 | GNU Affero General Public License into a single combined work, and to convey 524 | the resulting work. The terms of this License will continue to apply to the 525 | part which is the covered work, but the special requirements of the GNU Affero 526 | General Public License, section 13, concerning interaction through a network 527 | will apply to the combination as such. 528 | 529 | ### 14. Revised Versions of this License. 530 | 531 | The Free Software Foundation may publish revised and/or new versions of the GNU 532 | General Public License from time to time. Such new versions will be similar in 533 | spirit to the present version, but may differ in detail to address new problems 534 | or concerns. 535 | 536 | Each version is given a distinguishing version number. If the Program specifies 537 | that a certain numbered version of the GNU General Public License *or any later 538 | version* applies to it, you have the option of following the terms and 539 | conditions either of that numbered version or of any later version published by 540 | the Free Software Foundation. If the Program does not specify a version number 541 | of the GNU General Public License, you may choose any version ever published by 542 | the Free Software Foundation. 543 | 544 | If the Program specifies that a proxy can decide which future versions of the 545 | GNU General Public License can be used, that proxy's public statement of 546 | acceptance of a version permanently authorizes you to choose that version for 547 | the Program. 548 | 549 | Later license versions may give you additional or different permissions. 550 | However, no additional obligations are imposed on any author or copyright 551 | holder as a result of your choosing to follow a later version. 552 | 553 | ### 15. Disclaimer of Warranty. 554 | 555 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE 556 | LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER 557 | PARTIES PROVIDE THE PROGRAM *AS IS* WITHOUT WARRANTY OF ANY KIND, EITHER 558 | EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 559 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE 560 | QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE 561 | DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR 562 | CORRECTION. 563 | 564 | ### 16. Limitation of Liability. 565 | 566 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY 567 | COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS 568 | PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, 569 | INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE 570 | THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED 571 | INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE 572 | PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY 573 | HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 574 | 575 | ### 17. Interpretation of Sections 15 and 16. 576 | 577 | If the disclaimer of warranty and limitation of liability provided above cannot 578 | be given local legal effect according to their terms, reviewing courts shall 579 | apply local law that most closely approximates an absolute waiver of all civil 580 | liability in connection with the Program, unless a warranty or assumption of 581 | liability accompanies a copy of the Program in return for a fee. 582 | 583 | ## END OF TERMS AND CONDITIONS ### 584 | 585 | ### How to Apply These Terms to Your New Programs 586 | 587 | If you develop a new program, and you want it to be of the greatest possible 588 | use to the public, the best way to achieve this is to make it free software 589 | which everyone can redistribute and change under these terms. 590 | 591 | To do so, attach the following notices to the program. It is safest to attach 592 | them to the start of each source file to most effectively state the exclusion 593 | of warranty; and each file should have at least the *copyright* line and a 594 | pointer to where the full notice is found. 595 | 596 | 597 | Copyright (C) 598 | 599 | This program is free software: you can redistribute it and/or modify 600 | it under the terms of the GNU General Public License as published by 601 | the Free Software Foundation, either version 3 of the License, or 602 | (at your option) any later version. 603 | 604 | This program is distributed in the hope that it will be useful, 605 | but WITHOUT ANY WARRANTY; without even the implied warranty of 606 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 607 | GNU General Public License for more details. 608 | 609 | You should have received a copy of the GNU General Public License 610 | along with this program. If not, see . 611 | 612 | Also add information on how to contact you by electronic and paper mail. 613 | 614 | If the program does terminal interaction, make it output a short notice like 615 | this when it starts in an interactive mode: 616 | 617 | Copyright (C) 618 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 619 | This is free software, and you are welcome to redistribute it 620 | under certain conditions; type `show c' for details. 621 | 622 | The hypothetical commands `show w` and `show c` should show the appropriate 623 | parts of the General Public License. Of course, your program's commands might 624 | be different; for a GUI interface, you would use an *about box*. 625 | 626 | You should also get your employer (if you work as a programmer) or school, if 627 | any, to sign a *copyright disclaimer* for the program, if necessary. For more 628 | information on this, and how to apply and follow the GNU GPL, see 629 | [http://www.gnu.org/licenses/](http://www.gnu.org/licenses/). 630 | 631 | The GNU General Public License does not permit incorporating your program into 632 | proprietary programs. If your program is a subroutine library, you may consider 633 | it more useful to permit linking proprietary applications with the library. If 634 | this is what you want to do, use the GNU Lesser General Public License instead 635 | of this License. But first, please read 636 | [http://www.gnu.org/philosophy/why-not-lgpl.html](http://www.gnu.org/philosophy/why-not-lgpl.html). 637 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: build 2 | build: 3 | web-ext build -s ./src -n build.zip --overwrite-dest 4 | cd src && tar -czf ../web-ext-artifacts/build.tar.gz ./* 5 | 6 | .PHONY: lint 7 | lint: 8 | cd src && web-ext lint 9 | 10 | .PHONY: publish 11 | publish: 12 | web-ext sign \ 13 | --source-dir src \ 14 | --api-key $(ADDONS_MOZ_JWT_ISSUER) --api-secret $(ADDONS_MOZ_JWT_SECRET) \ 15 | --channel listed \ 16 | --approval-timeout 0 \ 17 | --amo-metadata ./amo-metadata.json -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # What-to-click logo What-to-click browser extension 2 | 3 | Tired of showing your teammates what to click in yet another web-based service added to your project? Worry not, you can now generate a step-by-step documentation of the workflow as you go! Start recording, go through the workflow, and adjust descriptions if necessary. 4 | 5 | ## What to click to use What-to-click 6 | 7 | 1. Visit the page you want to document. 8 | 1. Click the "red circle" browser action to start recording. 9 | 1. Perform necessary actions on the page. Each click will be recorded. 10 | 1. Click the "red square" browser action to stop recording. 11 | 1. A page with editable text will be opened, containing all of the steps you have performed with screenshots attached. Edit step descriptions to your liking and export or save the file. 12 | 13 | ## Get the addon 14 | 15 | ![Firefox addon rating](https://shields.io/amo/stars/what-to-click) 16 | 17 | [Get Firefox Addon](https://addons.mozilla.org/firefox/addon/what-to-click/) 18 | -------------------------------------------------------------------------------- /amo-metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": { 3 | "license": "LGPL-3.0-or-later" 4 | }, 5 | "categories": { 6 | "firefox": [ 7 | "other" 8 | ] 9 | }, 10 | "requires_payment": false, 11 | "homepage": { 12 | "en-US": "https://what-to-click.com" 13 | }, 14 | "support_email": { 15 | "en-US": "hey@what-to-click.com" 16 | } 17 | } -------------------------------------------------------------------------------- /docs/assets/get-the-addon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/what-to-click/browser-extension/23142661501f634a7440c592719af8aeb78738ec/docs/assets/get-the-addon.png -------------------------------------------------------------------------------- /src/.web-extension-id: -------------------------------------------------------------------------------- 1 | # This file was created by https://github.com/mozilla/web-ext 2 | # Your auto-generated extension ID for addons.mozilla.org is: 3 | {7feef224-a737-4d04-b0c1-ea47d4cad70a} -------------------------------------------------------------------------------- /src/background/background.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | What to click 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/background/helpers/localforage.min.js: -------------------------------------------------------------------------------- 1 | /*! 2 | localForage -- Offline Storage, Improved 3 | Version 1.10.0 4 | https://localforage.github.io/localForage 5 | (c) 2013-2017 Mozilla, Apache License 2.0 6 | */ 7 | !function(a){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=a();else if("function"==typeof define&&define.amd)define([],a);else{var b;b="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,b.localforage=a()}}(function(){return function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);var j=new Error("Cannot find module '"+g+"'");throw j.code="MODULE_NOT_FOUND",j}var k=c[g]={exports:{}};b[g][0].call(k.exports,function(a){var c=b[g][1][a];return e(c||a)},k,k.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g=43)}}).catch(function(){return!1})}function n(a){return"boolean"==typeof xa?va.resolve(xa):m(a).then(function(a){return xa=a})}function o(a){var b=ya[a.name],c={};c.promise=new va(function(a,b){c.resolve=a,c.reject=b}),b.deferredOperations.push(c),b.dbReady?b.dbReady=b.dbReady.then(function(){return c.promise}):b.dbReady=c.promise}function p(a){var b=ya[a.name],c=b.deferredOperations.pop();if(c)return c.resolve(),c.promise}function q(a,b){var c=ya[a.name],d=c.deferredOperations.pop();if(d)return d.reject(b),d.promise}function r(a,b){return new va(function(c,d){if(ya[a.name]=ya[a.name]||B(),a.db){if(!b)return c(a.db);o(a),a.db.close()}var e=[a.name];b&&e.push(a.version);var f=ua.open.apply(ua,e);b&&(f.onupgradeneeded=function(b){var c=f.result;try{c.createObjectStore(a.storeName),b.oldVersion<=1&&c.createObjectStore(wa)}catch(c){if("ConstraintError"!==c.name)throw c;console.warn('The database "'+a.name+'" has been upgraded from version '+b.oldVersion+" to version "+b.newVersion+', but the storage "'+a.storeName+'" already exists.')}}),f.onerror=function(a){a.preventDefault(),d(f.error)},f.onsuccess=function(){var b=f.result;b.onversionchange=function(a){a.target.close()},c(b),p(a)}})}function s(a){return r(a,!1)}function t(a){return r(a,!0)}function u(a,b){if(!a.db)return!0;var c=!a.db.objectStoreNames.contains(a.storeName),d=a.versiona.db.version;if(d&&(a.version!==b&&console.warn('The database "'+a.name+"\" can't be downgraded from version "+a.db.version+" to version "+a.version+"."),a.version=a.db.version),e||c){if(c){var f=a.db.version+1;f>a.version&&(a.version=f)}return!0}return!1}function v(a){return new va(function(b,c){var d=new FileReader;d.onerror=c,d.onloadend=function(c){var d=btoa(c.target.result||"");b({__local_forage_encoded_blob:!0,data:d,type:a.type})},d.readAsBinaryString(a)})}function w(a){return g([l(atob(a.data))],{type:a.type})}function x(a){return a&&a.__local_forage_encoded_blob}function y(a){var b=this,c=b._initReady().then(function(){var a=ya[b._dbInfo.name];if(a&&a.dbReady)return a.dbReady});return i(c,a,a),c}function z(a){o(a);for(var b=ya[a.name],c=b.forages,d=0;d0&&(!a.db||"InvalidStateError"===e.name||"NotFoundError"===e.name))return va.resolve().then(function(){if(!a.db||"NotFoundError"===e.name&&!a.db.objectStoreNames.contains(a.storeName)&&a.version<=a.db.version)return a.db&&(a.version=a.db.version+1),t(a)}).then(function(){return z(a).then(function(){A(a,b,c,d-1)})}).catch(c);c(e)}}function B(){return{forages:[],db:null,dbReady:null,deferredOperations:[]}}function C(a){function b(){return va.resolve()}var c=this,d={db:null};if(a)for(var e in a)d[e]=a[e];var f=ya[d.name];f||(f=B(),ya[d.name]=f),f.forages.push(c),c._initReady||(c._initReady=c.ready,c.ready=y);for(var g=[],h=0;h>4,k[i++]=(15&d)<<4|e>>2,k[i++]=(3&e)<<6|63&f;return j}function O(a){var b,c=new Uint8Array(a),d="";for(b=0;b>2],d+=Da[(3&c[b])<<4|c[b+1]>>4],d+=Da[(15&c[b+1])<<2|c[b+2]>>6],d+=Da[63&c[b+2]];return c.length%3==2?d=d.substring(0,d.length-1)+"=":c.length%3==1&&(d=d.substring(0,d.length-2)+"=="),d}function P(a,b){var c="";if(a&&(c=Ua.call(a)),a&&("[object ArrayBuffer]"===c||a.buffer&&"[object ArrayBuffer]"===Ua.call(a.buffer))){var d,e=Ga;a instanceof ArrayBuffer?(d=a,e+=Ia):(d=a.buffer,"[object Int8Array]"===c?e+=Ka:"[object Uint8Array]"===c?e+=La:"[object Uint8ClampedArray]"===c?e+=Ma:"[object Int16Array]"===c?e+=Na:"[object Uint16Array]"===c?e+=Pa:"[object Int32Array]"===c?e+=Oa:"[object Uint32Array]"===c?e+=Qa:"[object Float32Array]"===c?e+=Ra:"[object Float64Array]"===c?e+=Sa:b(new Error("Failed to get type for BinaryArray"))),b(e+O(d))}else if("[object Blob]"===c){var f=new FileReader;f.onload=function(){var c=Ea+a.type+"~"+O(this.result);b(Ga+Ja+c)},f.readAsArrayBuffer(a)}else try{b(JSON.stringify(a))}catch(c){console.error("Couldn't convert value into a JSON string: ",a),b(null,c)}}function Q(a){if(a.substring(0,Ha)!==Ga)return JSON.parse(a);var b,c=a.substring(Ta),d=a.substring(Ha,Ta);if(d===Ja&&Fa.test(c)){var e=c.match(Fa);b=e[1],c=c.substring(e[0].length)}var f=N(c);switch(d){case Ia:return f;case Ja:return g([f],{type:b});case Ka:return new Int8Array(f);case La:return new Uint8Array(f);case Ma:return new Uint8ClampedArray(f);case Na:return new Int16Array(f);case Pa:return new Uint16Array(f);case Oa:return new Int32Array(f);case Qa:return new Uint32Array(f);case Ra:return new Float32Array(f);case Sa:return new Float64Array(f);default:throw new Error("Unkown type: "+d)}}function R(a,b,c,d){a.executeSql("CREATE TABLE IF NOT EXISTS "+b.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],c,d)}function S(a){var b=this,c={db:null};if(a)for(var d in a)c[d]="string"!=typeof a[d]?a[d].toString():a[d];var e=new va(function(a,d){try{c.db=openDatabase(c.name,String(c.version),c.description,c.size)}catch(a){return d(a)}c.db.transaction(function(e){R(e,c,function(){b._dbInfo=c,a()},function(a,b){d(b)})},d)});return c.serializer=Va,e}function T(a,b,c,d,e,f){a.executeSql(c,d,e,function(a,g){g.code===g.SYNTAX_ERR?a.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[b.storeName],function(a,h){h.rows.length?f(a,g):R(a,b,function(){a.executeSql(c,d,e,f)},f)},f):f(a,g)},f)}function U(a,b){var c=this;a=j(a);var d=new va(function(b,d){c.ready().then(function(){var e=c._dbInfo;e.db.transaction(function(c){T(c,e,"SELECT * FROM "+e.storeName+" WHERE key = ? LIMIT 1",[a],function(a,c){var d=c.rows.length?c.rows.item(0).value:null;d&&(d=e.serializer.deserialize(d)),b(d)},function(a,b){d(b)})})}).catch(d)});return h(d,b),d}function V(a,b){var c=this,d=new va(function(b,d){c.ready().then(function(){var e=c._dbInfo;e.db.transaction(function(c){T(c,e,"SELECT * FROM "+e.storeName,[],function(c,d){for(var f=d.rows,g=f.length,h=0;h0)return void f(W.apply(e,[a,h,c,d-1]));g(b)}})})}).catch(g)});return h(f,c),f}function X(a,b,c){return W.apply(this,[a,b,c,1])}function Y(a,b){var c=this;a=j(a);var d=new va(function(b,d){c.ready().then(function(){var e=c._dbInfo;e.db.transaction(function(c){T(c,e,"DELETE FROM "+e.storeName+" WHERE key = ?",[a],function(){b()},function(a,b){d(b)})})}).catch(d)});return h(d,b),d}function Z(a){var b=this,c=new va(function(a,c){b.ready().then(function(){var d=b._dbInfo;d.db.transaction(function(b){T(b,d,"DELETE FROM "+d.storeName,[],function(){a()},function(a,b){c(b)})})}).catch(c)});return h(c,a),c}function $(a){var b=this,c=new va(function(a,c){b.ready().then(function(){var d=b._dbInfo;d.db.transaction(function(b){T(b,d,"SELECT COUNT(key) as c FROM "+d.storeName,[],function(b,c){var d=c.rows.item(0).c;a(d)},function(a,b){c(b)})})}).catch(c)});return h(c,a),c}function _(a,b){var c=this,d=new va(function(b,d){c.ready().then(function(){var e=c._dbInfo;e.db.transaction(function(c){T(c,e,"SELECT key FROM "+e.storeName+" WHERE id = ? LIMIT 1",[a+1],function(a,c){var d=c.rows.length?c.rows.item(0).key:null;b(d)},function(a,b){d(b)})})}).catch(d)});return h(d,b),d}function aa(a){var b=this,c=new va(function(a,c){b.ready().then(function(){var d=b._dbInfo;d.db.transaction(function(b){T(b,d,"SELECT key FROM "+d.storeName,[],function(b,c){for(var d=[],e=0;e '__WebKitDatabaseInfoTable__'",[],function(c,d){for(var e=[],f=0;f0}function ha(a){var b=this,c={};if(a)for(var d in a)c[d]=a[d];return c.keyPrefix=ea(a,b._defaultConfig),ga()?(b._dbInfo=c,c.serializer=Va,va.resolve()):va.reject()}function ia(a){var b=this,c=b.ready().then(function(){for(var a=b._dbInfo.keyPrefix,c=localStorage.length-1;c>=0;c--){var d=localStorage.key(c);0===d.indexOf(a)&&localStorage.removeItem(d)}});return h(c,a),c}function ja(a,b){var c=this;a=j(a);var d=c.ready().then(function(){var b=c._dbInfo,d=localStorage.getItem(b.keyPrefix+a);return d&&(d=b.serializer.deserialize(d)),d});return h(d,b),d}function ka(a,b){var c=this,d=c.ready().then(function(){for(var b=c._dbInfo,d=b.keyPrefix,e=d.length,f=localStorage.length,g=1,h=0;h=0;b--){var c=localStorage.key(b);0===c.indexOf(a)&&localStorage.removeItem(c)}}):va.reject("Invalid arguments"),h(d,b),d}function ra(a,b){a[b]=function(){var c=arguments;return a.ready().then(function(){return a[b].apply(a,c)})}}function sa(){for(var a=1;a { 2 | if (type === 'mousedown') { 3 | const currentSession = await localforage.getItem('currentSession'); 4 | if (currentSession == null) { 5 | return; 6 | } 7 | const sessionKey = `images-${currentSession}`; 8 | const screenshotPosition = calculateScreenshotPosition({ 9 | x: data.x, 10 | y: data.y, 11 | scrollX: data.scrollX, 12 | scrollY: data.scrollY, 13 | }, data.documentSize, data.size); 14 | const image = await browser.tabs.captureVisibleTab({ 15 | format: 'jpeg', 16 | quality: 95, 17 | rect: { 18 | x: screenshotPosition.x, 19 | y: screenshotPosition.y, 20 | width: data.size, 21 | height: data.size, 22 | } 23 | }); 24 | await localforage.setItem( 25 | sessionKey, 26 | [...await localforage.getItem(sessionKey) || [], { 27 | image, 28 | offset: screenshotPosition.offset, 29 | size: data.size, 30 | type: type, 31 | target: data.target, 32 | url: data.url, 33 | }] 34 | ); 35 | } else if (type === 'popstate') { 36 | const currentSession = await localforage.getItem('currentSession'); 37 | if (currentSession == null) { 38 | return; 39 | } 40 | const sessionKey = `images-${currentSession}`; 41 | await localforage.setItem( 42 | sessionKey, 43 | [...await localforage.getItem(sessionKey) || [], { 44 | type: type, 45 | url: data.url, 46 | }] 47 | ); 48 | } else if (type === 'fetchImages') { 49 | return await localforage.getItem(`images-${data.session}`) || []; 50 | } else if (type === 'fetchSessions') { 51 | return await localforage.getItem('sessions') || []; 52 | } else if (type === 'savePdf') { 53 | return await browser.tabs.saveAsPDF({ 54 | toFileName: `what-to-click-${new Date().toDateString()}.pdf`, 55 | footerLeft: '', 56 | footerRight: '', 57 | headerLeft: '', 58 | headerRight: '', 59 | }); 60 | } 61 | }); 62 | 63 | browser.browserAction.onClicked.addListener(async () => { 64 | const sessionActive = await localforage.getItem('currentSession'); 65 | if (sessionActive) { 66 | await localforage.setItem('currentSession', null); 67 | await browser.browserAction.setIcon({ path: '/icons/record.svg' }); 68 | await browser.browserAction.setBadgeText({ text: '' }); 69 | if ((await localforage.getItem(`images-${sessionActive}`)).length > 0) { 70 | await browser.tabs.create({ url: `/content/page.html?s=${encodeURIComponent(sessionActive)}`, active: false }); 71 | } 72 | } else { 73 | const session = new Date().toISOString(); 74 | await localforage.setItem('currentSession', session); 75 | await localforage.setItem('sessions', [...(await localforage.getItem('sessions') || []), session]); 76 | await browser.browserAction.setIcon({ path: '/icons/stop.svg' }); 77 | await browser.browserAction.setBadgeText({ text: 'live' }); 78 | } 79 | }); 80 | 81 | function calculateScreenshotPosition(clickPosition = { x: 0, y: 0, scrollX: 0, scrollY: 0 }, documentSize = { width: 0, height: 0 }, size = 300) { 82 | const x = clickPosition.x - size / 2; 83 | const y = clickPosition.y - size / 2; 84 | const rect = { 85 | top: y, 86 | left: x, 87 | bottom: y + size, 88 | right: x + size, 89 | }; 90 | const documentRect = { 91 | top: 0, 92 | left: 0, 93 | bottom: documentSize.height, 94 | right: documentSize.width, 95 | }; 96 | const offset = { 97 | top: Math.abs(Math.min(0, documentRect.top + rect.top + clickPosition.scrollY)), 98 | left: Math.abs(Math.min(0, documentRect.left + rect.left + clickPosition.scrollX)), 99 | bottom: Math.abs(Math.min(0, documentRect.bottom - rect.bottom + clickPosition.scrollY)), 100 | right: Math.abs(Math.min(0, documentRect.right - rect.right + clickPosition.scrollX)), 101 | }; 102 | 103 | // Avoid screenshots outside the document 104 | const correctedX = x + offset.left - offset.right; 105 | const correctedY = y + offset.top - offset.bottom; 106 | 107 | return { x: correctedX, y: correctedY, offset }; 108 | } 109 | 110 | browser.webNavigation.onCommitted.addListener(async (event) => { 111 | const currentSession = await localforage.getItem('currentSession'); 112 | if (currentSession == null) { 113 | return; 114 | } 115 | 116 | if (event.transitionQualifiers.includes('forward_back')) { 117 | const sessionKey = `images-${currentSession}`; 118 | await localforage.setItem( 119 | sessionKey, 120 | [...await localforage.getItem(sessionKey) || [], { 121 | type: 'backNavigation', 122 | url: event.url, 123 | }] 124 | ); 125 | } 126 | }); -------------------------------------------------------------------------------- /src/content/assets/logo.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 37 | 39 | 42 | 45 | 49 | 53 | 54 | 55 | 60 | 61 | -------------------------------------------------------------------------------- /src/content/deps/eng-fast.traineddata.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/what-to-click/browser-extension/23142661501f634a7440c592719af8aeb78738ec/src/content/deps/eng-fast.traineddata.gz -------------------------------------------------------------------------------- /src/content/deps/mini-van-0.3.8.min.js: -------------------------------------------------------------------------------- 1 | let t=Object,e=e=>{let l={add:(t,...e)=>(t.append(...e.flat(1/0).filter(t=>null!=t)),t),tags:new Proxy((n,...o)=>{let[d,...r]=o[0]?.constructor===t?o:[{},...o],u=e.createElement(n);for(let[e,l]of t.entries(d))void 0!==u[e]?u[e]=l:u.setAttribute(e,l);return l.add(u,...r)},{get:(t,e)=>t.bind(null,e)}),html:(...t)=>""+l.tags.html(...t).outerHTML};return l};export default{vanWithDoc:e,...e("undefined"!=typeof window?window.document:null)}; -------------------------------------------------------------------------------- /src/content/deps/tesseract-core-simd.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/what-to-click/browser-extension/23142661501f634a7440c592719af8aeb78738ec/src/content/deps/tesseract-core-simd.wasm -------------------------------------------------------------------------------- /src/content/deps/tesseract@4.0.5.min.js: -------------------------------------------------------------------------------- 1 | /*! For license information please see tesseract.min.js.LICENSE.txt */ 2 | !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Tesseract=e():t.Tesseract=e()}(self,(()=>(()=>{var t={670:t=>{function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},e(t)}t.exports=function(){return"undefined"!=typeof window&&"object"===e(window.process)&&"renderer"===window.process.type||!("undefined"==typeof process||"object"!==e(process.versions)||!process.versions.electron)||"object"===("undefined"==typeof navigator?"undefined":e(navigator))&&"string"==typeof navigator.userAgent&&navigator.userAgent.indexOf("Electron")>=0}},760:(t,e,r)=>{function n(t){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(t)}var o=function(t){"use strict";var e,r=Object.prototype,o=r.hasOwnProperty,i=Object.defineProperty||function(t,e,r){t[e]=r.value},a="function"==typeof Symbol?Symbol:{},c=a.iterator||"@@iterator",u=a.asyncIterator||"@@asyncIterator",s=a.toStringTag||"@@toStringTag";function l(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{l({},"")}catch(t){l=function(t,e,r){return t[e]=r}}function f(t,e,r,n){var o=e&&e.prototype instanceof m?e:m,a=Object.create(o.prototype),c=new T(n||[]);return i(a,"_invoke",{value:k(t,r,c)}),a}function p(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=f;var h="suspendedStart",y="suspendedYield",d="executing",v="completed",g={};function m(){}function b(){}function w(){}var x={};l(x,c,(function(){return this}));var O=Object.getPrototypeOf,L=O&&O(O(A([])));L&&L!==r&&o.call(L,c)&&(x=L);var E=w.prototype=m.prototype=Object.create(x);function j(t){["next","throw","return"].forEach((function(e){l(t,e,(function(t){return this._invoke(e,t)}))}))}function S(t,e){function r(i,a,c,u){var s=p(t[i],t,a);if("throw"!==s.type){var l=s.arg,f=l.value;return f&&"object"===n(f)&&o.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,c,u)}),(function(t){r("throw",t,c,u)})):e.resolve(f).then((function(t){l.value=t,c(l)}),(function(t){return r("throw",t,c,u)}))}u(s.arg)}var a;i(this,"_invoke",{value:function(t,n){function o(){return new e((function(e,o){r(t,n,e,o)}))}return a=a?a.then(o,o):o()}})}function k(t,e,r){var n=h;return function(o,i){if(n===d)throw new Error("Generator is already running");if(n===v){if("throw"===o)throw i;return G()}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var c=P(a,r);if(c){if(c===g)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(n===h)throw n=v,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n=d;var u=p(t,e,r);if("normal"===u.type){if(n=r.done?v:y,u.arg===g)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n=v,r.method="throw",r.arg=u.arg)}}}function P(t,r){var n=r.method,o=t.iterator[n];if(o===e)return r.delegate=null,"throw"===n&&t.iterator.return&&(r.method="return",r.arg=e,P(t,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),g;var i=p(o,t.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,g;var a=i.arg;return a?a.done?(r[t.resultName]=a.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,g):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,g)}function _(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function N(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function T(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(_,this),this.reset(!0)}function A(t){if(t){var r=t[c];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function r(){for(;++n=0;--i){var a=this.tryEntries[i],c=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var u=o.call(a,"catchLoc"),s=o.call(a,"finallyLoc");if(u&&s){if(this.prev=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&o.call(n,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),N(r),g}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;N(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:A(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),g}},t}("object"===n(t=r.nmd(t))?t.exports:{});try{regeneratorRuntime=o}catch(t){"object"===("undefined"==typeof globalThis?"undefined":n(globalThis))?globalThis.regeneratorRuntime=o:Function("r","regeneratorRuntime = r")(o)}},927:function(t,e,r){var n,o;n=function(){return function(){var t=arguments.length;if(0===t)throw new Error("resolveUrl requires at least one argument; got none.");var e=document.createElement("base");if(e.href=arguments[0],1===t)return e.href;var r=document.getElementsByTagName("head")[0];r.insertBefore(e,r.firstChild);for(var n,o=document.createElement("a"),i=1;i{function n(t){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(t)}function o(){"use strict";o=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,i=Object.defineProperty||function(t,e,r){t[e]=r.value},a="function"==typeof Symbol?Symbol:{},c=a.iterator||"@@iterator",u=a.asyncIterator||"@@asyncIterator",s=a.toStringTag||"@@toStringTag";function l(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{l({},"")}catch(t){l=function(t,e,r){return t[e]=r}}function f(t,e,r,n){var o=e&&e.prototype instanceof y?e:y,a=Object.create(o.prototype),c=new k(n||[]);return i(a,"_invoke",{value:L(t,r,c)}),a}function p(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=f;var h={};function y(){}function d(){}function v(){}var g={};l(g,c,(function(){return this}));var m=Object.getPrototypeOf,b=m&&m(m(P([])));b&&b!==e&&r.call(b,c)&&(g=b);var w=v.prototype=y.prototype=Object.create(g);function x(t){["next","throw","return"].forEach((function(e){l(t,e,(function(t){return this._invoke(e,t)}))}))}function O(t,e){function o(i,a,c,u){var s=p(t[i],t,a);if("throw"!==s.type){var l=s.arg,f=l.value;return f&&"object"==n(f)&&r.call(f,"__await")?e.resolve(f.__await).then((function(t){o("next",t,c,u)}),(function(t){o("throw",t,c,u)})):e.resolve(f).then((function(t){l.value=t,c(l)}),(function(t){return o("throw",t,c,u)}))}u(s.arg)}var a;i(this,"_invoke",{value:function(t,r){function n(){return new e((function(e,n){o(t,r,e,n)}))}return a=a?a.then(n,n):n()}})}function L(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var c=E(a,r);if(c){if(c===h)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=p(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===h)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}function E(t,e){var r=e.method,n=t.iterator[r];if(void 0===n)return e.delegate=null,"throw"===r&&t.iterator.return&&(e.method="return",e.arg=void 0,E(t,e),"throw"===e.method)||"return"!==r&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+r+"' method")),h;var o=p(n,t.iterator,e.arg);if("throw"===o.type)return e.method="throw",e.arg=o.arg,e.delegate=null,h;var i=o.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,h):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,h)}function j(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function S(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function k(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(j,this),this.reset(!0)}function P(t){if(t){var e=t[c];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,o=function e(){for(;++n=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),S(r),h}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;S(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:P(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),h}},t}function i(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function a(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var a=t.apply(e,r);function c(t){i(a,n,o,c,u,"next",t)}function u(t){i(a,n,o,c,u,"throw",t)}c(void 0)}))}}var c=r(311),u=function(){var t=a(o().mark((function t(e,r,n){var i;return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,c(n);case 2:return i=t.sent,t.next=5,i.loadLanguage(r);case 5:return t.next=7,i.initialize(r);case 7:return t.abrupt("return",i.recognize(e).finally(a(o().mark((function t(){return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,i.terminate();case 2:case"end":return t.stop()}}),t)})))));case 8:case"end":return t.stop()}}),t)})));return function(e,r,n){return t.apply(this,arguments)}}(),s=function(){var t=a(o().mark((function t(e,r){var n;return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,c(r);case 2:return n=t.sent,t.next=5,n.loadLanguage("osd");case 5:return t.next=7,n.initialize("osd");case 7:return t.abrupt("return",n.detect(e).finally(a(o().mark((function t(){return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,n.terminate();case 2:case"end":return t.stop()}}),t)})))));case 8:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}();t.exports={recognize:u,detect:s}},847:t=>{t.exports={TESSERACT_ONLY:0,LSTM_ONLY:1,TESSERACT_LSTM_COMBINED:2,DEFAULT:3}},711:t=>{t.exports={OSD_ONLY:"0",AUTO_OSD:"1",AUTO_ONLY:"2",AUTO:"3",SINGLE_COLUMN:"4",SINGLE_BLOCK_VERT_TEXT:"5",SINGLE_BLOCK:"6",SINGLE_LINE:"7",SINGLE_WORD:"8",CIRCLE_WORD:"9",SINGLE_CHAR:"10",SPARSE_TEXT:"11",SPARSE_TEXT_OSD:"12",RAW_LINE:"13"}},214:(t,e,r)=>{var n=r(847);t.exports={defaultOEM:n.DEFAULT}},341:t=>{t.exports={langPath:"https://tessdata.projectnaptha.com/4.0.0",workerBlobURL:!0,logger:function(){}}},5:t=>{t.exports={AFR:"afr",AMH:"amh",ARA:"ara",ASM:"asm",AZE:"aze",AZE_CYRL:"aze_cyrl",BEL:"bel",BEN:"ben",BOD:"bod",BOS:"bos",BUL:"bul",CAT:"cat",CEB:"ceb",CES:"ces",CHI_SIM:"chi_sim",CHI_TRA:"chi_tra",CHR:"chr",CYM:"cym",DAN:"dan",DEU:"deu",DZO:"dzo",ELL:"ell",ENG:"eng",ENM:"enm",EPO:"epo",EST:"est",EUS:"eus",FAS:"fas",FIN:"fin",FRA:"fra",FRK:"frk",FRM:"frm",GLE:"gle",GLG:"glg",GRC:"grc",GUJ:"guj",HAT:"hat",HEB:"heb",HIN:"hin",HRV:"hrv",HUN:"hun",IKU:"iku",IND:"ind",ISL:"isl",ITA:"ita",ITA_OLD:"ita_old",JAV:"jav",JPN:"jpn",KAN:"kan",KAT:"kat",KAT_OLD:"kat_old",KAZ:"kaz",KHM:"khm",KIR:"kir",KOR:"kor",KUR:"kur",LAO:"lao",LAT:"lat",LAV:"lav",LIT:"lit",MAL:"mal",MAR:"mar",MKD:"mkd",MLT:"mlt",MSA:"msa",MYA:"mya",NEP:"nep",NLD:"nld",NOR:"nor",ORI:"ori",PAN:"pan",POL:"pol",POR:"por",PUS:"pus",RON:"ron",RUS:"rus",SAN:"san",SIN:"sin",SLK:"slk",SLV:"slv",SPA:"spa",SPA_OLD:"spa_old",SQI:"sqi",SRP:"srp",SRP_LATN:"srp_latn",SWA:"swa",SWE:"swe",SYR:"syr",TAM:"tam",TEL:"tel",TGK:"tgk",TGL:"tgl",THA:"tha",TIR:"tir",TUR:"tur",UIG:"uig",UKR:"ukr",URD:"urd",UZB:"uzb",UZB_CYRL:"uzb_cyrl",VIE:"vie",YID:"yid"}},106:(t,e,r)=>{var n=r(313),o=0;t.exports=function(t){var e=t.id,r=t.action,i=t.payload,a=void 0===i?{}:i,c=e;return void 0===c&&(c=n("Job",o),o+=1),{id:c,action:r,payload:a}}},936:function(t,e,r){function n(t){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(t)}var o=this;function i(){"use strict";i=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,o=Object.defineProperty||function(t,e,r){t[e]=r.value},a="function"==typeof Symbol?Symbol:{},c=a.iterator||"@@iterator",u=a.asyncIterator||"@@asyncIterator",s=a.toStringTag||"@@toStringTag";function l(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{l({},"")}catch(t){l=function(t,e,r){return t[e]=r}}function f(t,e,r,n){var i=e&&e.prototype instanceof y?e:y,a=Object.create(i.prototype),c=new k(n||[]);return o(a,"_invoke",{value:L(t,r,c)}),a}function p(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=f;var h={};function y(){}function d(){}function v(){}var g={};l(g,c,(function(){return this}));var m=Object.getPrototypeOf,b=m&&m(m(P([])));b&&b!==e&&r.call(b,c)&&(g=b);var w=v.prototype=y.prototype=Object.create(g);function x(t){["next","throw","return"].forEach((function(e){l(t,e,(function(t){return this._invoke(e,t)}))}))}function O(t,e){function i(o,a,c,u){var s=p(t[o],t,a);if("throw"!==s.type){var l=s.arg,f=l.value;return f&&"object"==n(f)&&r.call(f,"__await")?e.resolve(f.__await).then((function(t){i("next",t,c,u)}),(function(t){i("throw",t,c,u)})):e.resolve(f).then((function(t){l.value=t,c(l)}),(function(t){return i("throw",t,c,u)}))}u(s.arg)}var a;o(this,"_invoke",{value:function(t,r){function n(){return new e((function(e,n){i(t,r,e,n)}))}return a=a?a.then(n,n):n()}})}function L(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var c=E(a,r);if(c){if(c===h)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=p(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===h)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}function E(t,e){var r=e.method,n=t.iterator[r];if(void 0===n)return e.delegate=null,"throw"===r&&t.iterator.return&&(e.method="return",e.arg=void 0,E(t,e),"throw"===e.method)||"return"!==r&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+r+"' method")),h;var o=p(n,t.iterator,e.arg);if("throw"===o.type)return e.method="throw",e.arg=o.arg,e.delegate=null,h;var i=o.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,h):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,h)}function j(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function S(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function k(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(j,this),this.reset(!0)}function P(t){if(t){var e=t[c];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,o=function e(){for(;++n=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),S(r),h}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;S(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:P(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),h}},t}function a(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r1?n-1:0),a=1;a=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),S(r),h}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;S(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:P(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),h}},t}function a(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function c(t){for(var e=1;e=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}function l(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function f(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){l(i,n,o,a,c,"next",t)}function c(t){l(i,n,o,a,c,"throw",t)}a(void 0)}))}}var p=r(187),h=r(549),y=r(106),d=r(185).log,v=r(313),g=r(214).defaultOEM,m=r(581),b=m.defaultOptions,w=m.spawnWorker,x=m.terminateWorker,O=m.onMessage,L=m.loadImage,E=m.send,j=0;t.exports=f(i().mark((function t(){var e,r,n,a,u,l,m,S,k,P,_,N,T,A,G,I,F,R,D,M,U,C,z,Y,B,K,W,H,J,V,Z=arguments;return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=Z.length>0&&void 0!==Z[0]?Z[0]:{},r=v("Worker",j),n=p(c(c({},b),e)),a=n.logger,u=n.errorHandler,l=s(n,o),m={},S={},_=new Promise((function(t,e){P=t,k=e})),N=function(t){k(t.message)},(T=w(l)).onerror=N,j+=1,A=function(t,e){m[t]=e},G=function(t,e){S[t]=e},I=function(t){var e=t.id,n=t.action,o=t.payload;return new Promise((function(t,i){d("[".concat(r,"]: Start ").concat(e,", action=").concat(n)),A(n,t),G(n,i),E(T,{workerId:r,jobId:e,action:n,payload:o})}))},F=function(){return console.warn("`load` is depreciated and should be removed from code (workers now come pre-loaded)")},R=function(t){return I(y({id:t,action:"load",payload:{options:l}}))},D=function(t,e,r){return I(y({id:r,action:"FS",payload:{method:"writeFile",args:[t,e]}}))},M=function(t,e){return I(y({id:e,action:"FS",payload:{method:"readFile",args:[t,{encoding:"utf8"}]}}))},U=function(t,e){return I(y({id:e,action:"FS",payload:{method:"unlink",args:[t]}}))},C=function(t,e,r){return I(y({id:r,action:"FS",payload:{method:t,args:e}}))},z=function(){return I(y({id:arguments.length>1?arguments[1]:void 0,action:"loadLanguage",payload:{langs:arguments.length>0&&void 0!==arguments[0]?arguments[0]:"eng",options:l}}))},Y=function(){return I(y({id:arguments.length>3?arguments[3]:void 0,action:"initialize",payload:{langs:arguments.length>0&&void 0!==arguments[0]?arguments[0]:"eng",oem:arguments.length>1&&void 0!==arguments[1]?arguments[1]:g,config:arguments.length>2?arguments[2]:void 0}}))},B=function(){return I(y({id:arguments.length>1?arguments[1]:void 0,action:"setParameters",payload:{params:arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}}}))},K=function(){var t=f(i().mark((function t(e){var r,n,o,a=arguments;return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=a.length>1&&void 0!==a[1]?a[1]:{},n=a.length>2&&void 0!==a[2]?a[2]:{blocks:!0,text:!0,hocr:!0,tsv:!0},o=a.length>3?a[3]:void 0,t.t0=I,t.t1=y,t.t2=o,t.next=8,L(e);case 8:return t.t3=t.sent,t.t4=r,t.t5=n,t.t6={image:t.t3,options:t.t4,output:t.t5},t.t7={id:t.t2,action:"recognize",payload:t.t6},t.t8=(0,t.t1)(t.t7),t.abrupt("return",(0,t.t0)(t.t8));case 15:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),W=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Tesseract OCR Result",e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=arguments.length>2?arguments[2]:void 0;return console.log("`getPDF` function is depreciated. `recognize` option `savePDF` should be used instead."),I(y({id:r,action:"getPDF",payload:{title:t,textonly:e}}))},H=function(){var t=f(i().mark((function t(e,r){return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.t0=I,t.t1=y,t.t2=r,t.next=5,L(e);case 5:return t.t3=t.sent,t.t4={image:t.t3},t.t5={id:t.t2,action:"detect",payload:t.t4},t.t6=(0,t.t1)(t.t5),t.abrupt("return",(0,t.t0)(t.t6));case 10:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}(),J=function(){var t=f(i().mark((function t(){return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return null!==T&&(x(T),T=null),t.abrupt("return",Promise.resolve());case 2:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}(),O(T,(function(t){var e=t.workerId,r=t.jobId,n=t.status,o=t.action,i=t.data;if("resolve"===n){d("[".concat(e,"]: Complete ").concat(r));var s=i;"recognize"===o?s=h(i):"getPDF"===o&&(s=Array.from(c(c({},i),{},{length:Object.keys(i).length}))),m[o]({jobId:r,data:s})}else if("reject"===n){if(S[o](i),"load"===o&&k(i),!u)throw Error(i);u(i)}else"progress"===n&&a(c(c({},i),{},{userJobId:r}))})),V={id:r,worker:T,setResolve:A,setReject:G,load:F,writeText:D,readText:M,removeFile:U,FS:C,loadLanguage:z,initialize:Y,setParameters:B,recognize:K,getPDF:W,detect:H,terminate:J},R().then((function(){return P(V)})).catch((function(){})),t.abrupt("return",_);case 30:case"end":return t.stop()}}),t)})))},352:(t,e,r)=>{function n(t){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(t)}function o(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function i(t,e,r){return(e=function(t){var e=function(t,e){if("object"!==n(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var o=r.call(t,"string");if("object"!==n(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"===n(e)?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}r(760);var a=r(936),c=r(311),u=r(793),s=r(5),l=r(847),f=r(711),p=r(185).setLogging;t.exports=function(t){for(var e=1;e{function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},e(t)}function r(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function n(t){for(var e=1;e{function n(t){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(t)}var o=r(670);t.exports=function(t){var e={};return"undefined"!=typeof WorkerGlobalScope?e.type="webworker":o()?e.type="electron":"object"===("undefined"==typeof window?"undefined":n(window))?e.type="browser":"object"===("undefined"==typeof process?"undefined":n(process))&&(e.type="node"),void 0===t?e:e[t]}},313:t=>{t.exports=function(t,e){return"".concat(t,"-").concat(e,"-").concat(Math.random().toString(16).slice(3,8))}},185:function(t,e){var r=this,n=!1;e.logging=n,e.setLogging=function(t){n=t},e.log=function(){for(var t=arguments.length,e=new Array(t),o=0;o{function n(t){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(t)}function o(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function i(t,e,r){return(e=function(t){var e=function(t,e){if("object"!==n(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var o=r.call(t,"string");if("object"!==n(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"===n(e)?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var a="browser"===r(129)("type")?r(927):function(t){return t};t.exports=function(t){var e=function(t){for(var e=1;e{function n(t){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(t)}function o(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function i(t){for(var e=1;e{var n=r(854),o=r(676),i=r(100),a=r(202),c=r(772),u=r(931);t.exports={defaultOptions:n,spawnWorker:o,terminateWorker:i,onMessage:a,send:c,loadImage:u}},931:(t,e,r)=>{function n(t){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(t)}function o(){"use strict";o=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,i=Object.defineProperty||function(t,e,r){t[e]=r.value},a="function"==typeof Symbol?Symbol:{},c=a.iterator||"@@iterator",u=a.asyncIterator||"@@asyncIterator",s=a.toStringTag||"@@toStringTag";function l(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{l({},"")}catch(t){l=function(t,e,r){return t[e]=r}}function f(t,e,r,n){var o=e&&e.prototype instanceof y?e:y,a=Object.create(o.prototype),c=new k(n||[]);return i(a,"_invoke",{value:L(t,r,c)}),a}function p(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=f;var h={};function y(){}function d(){}function v(){}var g={};l(g,c,(function(){return this}));var m=Object.getPrototypeOf,b=m&&m(m(P([])));b&&b!==e&&r.call(b,c)&&(g=b);var w=v.prototype=y.prototype=Object.create(g);function x(t){["next","throw","return"].forEach((function(e){l(t,e,(function(t){return this._invoke(e,t)}))}))}function O(t,e){function o(i,a,c,u){var s=p(t[i],t,a);if("throw"!==s.type){var l=s.arg,f=l.value;return f&&"object"==n(f)&&r.call(f,"__await")?e.resolve(f.__await).then((function(t){o("next",t,c,u)}),(function(t){o("throw",t,c,u)})):e.resolve(f).then((function(t){l.value=t,c(l)}),(function(t){return o("throw",t,c,u)}))}u(s.arg)}var a;i(this,"_invoke",{value:function(t,r){function n(){return new e((function(e,n){o(t,r,e,n)}))}return a=a?a.then(n,n):n()}})}function L(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var c=E(a,r);if(c){if(c===h)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=p(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===h)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}function E(t,e){var r=e.method,n=t.iterator[r];if(void 0===n)return e.delegate=null,"throw"===r&&t.iterator.return&&(e.method="return",e.arg=void 0,E(t,e),"throw"===e.method)||"return"!==r&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+r+"' method")),h;var o=p(n,t.iterator,e.arg);if("throw"===o.type)return e.method="throw",e.arg=o.arg,e.delegate=null,h;var i=o.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,h):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,h)}function j(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function S(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function k(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(j,this),this.reset(!0)}function P(t){if(t){var e=t[c];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,o=function e(){for(;++n=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),S(r),h}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;S(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:P(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),h}},t}function i(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function a(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var a=t.apply(e,r);function c(t){i(a,n,o,c,u,"next",t)}function u(t){i(a,n,o,c,u,"throw",t)}c(void 0)}))}}var c=r(927),u=function(t){return new Promise((function(e,r){var n=new FileReader;n.onload=function(){e(n.result)},n.onerror=function(t){var e=t.target.error.code;r(Error("File could not be read! Code=".concat(e)))},n.readAsArrayBuffer(t)}))},s=function(){var t=a(o().mark((function t(e){var r,n;return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=e,void 0!==e){t.next=3;break}return t.abrupt("return","undefined");case 3:if("string"!=typeof e){t.next=16;break}if(!/data:image\/([a-zA-Z]*);base64,([^"]*)/.test(e)){t.next=8;break}r=atob(e.split(",")[1]).split("").map((function(t){return t.charCodeAt(0)})),t.next=14;break;case 8:return t.next=10,fetch(c(e));case 10:return n=t.sent,t.next=13,n.arrayBuffer();case 13:r=t.sent;case 14:t.next=34;break;case 16:if(!(e instanceof HTMLElement)){t.next=30;break}if("IMG"!==e.tagName){t.next=21;break}return t.next=20,s(e.src);case 20:r=t.sent;case 21:if("VIDEO"!==e.tagName){t.next=25;break}return t.next=24,s(e.poster);case 24:r=t.sent;case 25:if("CANVAS"!==e.tagName){t.next=28;break}return t.next=28,new Promise((function(t){e.toBlob(function(){var e=a(o().mark((function e(n){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,u(n);case 2:r=e.sent,t();case 4:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}())}));case 28:t.next=34;break;case 30:if(!(e instanceof File||e instanceof Blob)){t.next=34;break}return t.next=33,u(e);case 33:r=t.sent;case 34:return t.abrupt("return",new Uint8Array(r));case 35:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}();t.exports=s},202:t=>{t.exports=function(t,e){t.onmessage=function(t){var r=t.data;e(r)}}},772:t=>{function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},e(t)}function r(){"use strict";r=function(){return t};var t={},n=Object.prototype,o=n.hasOwnProperty,i=Object.defineProperty||function(t,e,r){t[e]=r.value},a="function"==typeof Symbol?Symbol:{},c=a.iterator||"@@iterator",u=a.asyncIterator||"@@asyncIterator",s=a.toStringTag||"@@toStringTag";function l(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{l({},"")}catch(t){l=function(t,e,r){return t[e]=r}}function f(t,e,r,n){var o=e&&e.prototype instanceof y?e:y,a=Object.create(o.prototype),c=new k(n||[]);return i(a,"_invoke",{value:L(t,r,c)}),a}function p(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=f;var h={};function y(){}function d(){}function v(){}var g={};l(g,c,(function(){return this}));var m=Object.getPrototypeOf,b=m&&m(m(P([])));b&&b!==n&&o.call(b,c)&&(g=b);var w=v.prototype=y.prototype=Object.create(g);function x(t){["next","throw","return"].forEach((function(e){l(t,e,(function(t){return this._invoke(e,t)}))}))}function O(t,r){function n(i,a,c,u){var s=p(t[i],t,a);if("throw"!==s.type){var l=s.arg,f=l.value;return f&&"object"==e(f)&&o.call(f,"__await")?r.resolve(f.__await).then((function(t){n("next",t,c,u)}),(function(t){n("throw",t,c,u)})):r.resolve(f).then((function(t){l.value=t,c(l)}),(function(t){return n("throw",t,c,u)}))}u(s.arg)}var a;i(this,"_invoke",{value:function(t,e){function o(){return new r((function(r,o){n(t,e,r,o)}))}return a=a?a.then(o,o):o()}})}function L(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var c=E(a,r);if(c){if(c===h)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=p(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===h)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}function E(t,e){var r=e.method,n=t.iterator[r];if(void 0===n)return e.delegate=null,"throw"===r&&t.iterator.return&&(e.method="return",e.arg=void 0,E(t,e),"throw"===e.method)||"return"!==r&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+r+"' method")),h;var o=p(n,t.iterator,e.arg);if("throw"===o.type)return e.method="throw",e.arg=o.arg,e.delegate=null,h;var i=o.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,h):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,h)}function j(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function S(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function k(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(j,this),this.reset(!0)}function P(t){if(t){var e=t[c];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,n=function e(){for(;++r=0;--n){var i=this.tryEntries[n],a=i.completion;if("root"===i.tryLoc)return r("end");if(i.tryLoc<=this.prev){var c=o.call(i,"catchLoc"),u=o.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&o.call(n,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),S(r),h}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;S(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:P(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),h}},t}function n(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}t.exports=function(){var t,e=(t=r().mark((function t(e,n){return r().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e.postMessage(n);case 1:case"end":return t.stop()}}),t)})),function(){var e=this,r=arguments;return new Promise((function(o,i){var a=t.apply(e,r);function c(t){n(a,o,i,c,u,"next",t)}function u(t){n(a,o,i,c,u,"throw",t)}c(void 0)}))});return function(t,r){return e.apply(this,arguments)}}()},676:t=>{t.exports=function(t){var e,r=t.workerPath,n=t.workerBlobURL;if(Blob&&URL&&n){var o=new Blob(['importScripts("'.concat(r,'");')],{type:"application/javascript"});e=new Worker(URL.createObjectURL(o))}else e=new Worker(r);return e}},100:t=>{t.exports=function(t){t.terminate()}},147:t=>{"use strict";t.exports=JSON.parse('{"name":"tesseract.js","version":"4.0.5","description":"Pure Javascript Multilingual OCR","main":"src/index.js","types":"src/index.d.ts","unpkg":"dist/tesseract.min.js","jsdelivr":"dist/tesseract.min.js","scripts":{"start":"node scripts/server.js","build":"rimraf dist && webpack --config scripts/webpack.config.prod.js && rollup -c scripts/rollup.esm.mjs","profile:tesseract":"webpack-bundle-analyzer dist/tesseract-stats.json","profile:worker":"webpack-bundle-analyzer dist/worker-stats.json","prepublishOnly":"npm run build","wait":"rimraf dist && wait-on http://localhost:3000/dist/tesseract.dev.js","test":"npm-run-all -p -r start test:all","test:all":"npm-run-all wait test:browser:* test:node:all","test:node":"nyc mocha --exit --bail --require ./scripts/test-helper.js","test:node:all":"npm run test:node -- ./tests/*.test.js","test:browser-tpl":"mocha-headless-chrome -a incognito -a no-sandbox -a disable-setuid-sandbox -a disable-logging -t 300000","test:browser:detect":"npm run test:browser-tpl -- -f ./tests/detect.test.html","test:browser:recognize":"npm run test:browser-tpl -- -f ./tests/recognize.test.html","test:browser:scheduler":"npm run test:browser-tpl -- -f ./tests/scheduler.test.html","test:browser:FS":"npm run test:browser-tpl -- -f ./tests/FS.test.html","lint":"eslint src","lint:fix":"eslint --fix src","postinstall":"opencollective-postinstall || true"},"browser":{"./src/worker/node/index.js":"./src/worker/browser/index.js"},"author":"","contributors":["jeromewu"],"license":"Apache-2.0","devDependencies":{"@babel/core":"^7.21.4","@babel/eslint-parser":"^7.21.3","@babel/preset-env":"^7.21.4","@rollup/plugin-commonjs":"^24.1.0","acorn":"^8.8.2","babel-loader":"^9.1.2","buffer":"^6.0.3","cors":"^2.8.5","eslint":"^7.32.0","eslint-config-airbnb-base":"^14.2.1","eslint-plugin-import":"^2.27.5","expect.js":"^0.3.1","express":"^4.18.2","mocha":"^10.2.0","mocha-headless-chrome":"^4.0.0","npm-run-all":"^4.1.5","nyc":"^15.1.0","rimraf":"^5.0.0","rollup":"^3.20.7","wait-on":"^7.0.1","webpack":"^5.79.0","webpack-bundle-analyzer":"^4.8.0","webpack-cli":"^5.0.1","webpack-dev-middleware":"^6.0.2"},"dependencies":{"bmp-js":"^0.1.0","file-type":"^12.4.2","idb-keyval":"^6.2.0","is-electron":"^2.2.2","is-url":"^1.2.4","node-fetch":"^2.6.9","opencollective-postinstall":"^2.0.3","regenerator-runtime":"^0.13.3","resolve-url":"^0.2.1","tesseract.js-core":"^4.0.4","wasm-feature-detect":"^1.2.11","zlibjs":"^0.3.1"},"repository":{"type":"git","url":"https://github.com/naptha/tesseract.js.git"},"bugs":{"url":"https://github.com/naptha/tesseract.js/issues"},"homepage":"https://github.com/naptha/tesseract.js","collective":{"type":"opencollective","url":"https://opencollective.com/tesseractjs"}}')}},e={};function r(n){var o=e[n];if(void 0!==o)return o.exports;var i=e[n]={id:n,loaded:!1,exports:{}};return t[n].call(i.exports,i,i.exports,r),i.loaded=!0,i.exports}return r.nmd=t=>(t.paths=[],t.children||(t.children=[]),t),r(352)})())); 3 | //# sourceMappingURL=tesseract.min.js.map -------------------------------------------------------------------------------- /src/content/index.js: -------------------------------------------------------------------------------- 1 | async function sendMessageToBg({ type = 'general', data = {} } = {}) { 2 | try { 3 | const response = await browser.runtime.sendMessage({ type, data }); 4 | return response; 5 | } catch (error) { 6 | console.error("sendMessageToBackground error: ", error); 7 | return null; 8 | } 9 | } 10 | 11 | document.addEventListener('mousedown', ({ pageX, pageY, target }) => { 12 | sendMessageToBg(createMouseDownRecord(pageX, pageY, window.scrollX, window.scrollY, target)); 13 | }); 14 | 15 | function createMouseDownRecord(pageX, pageY, scrollX, scrollY, target) { 16 | const imageSize = Math.max(window.screen.availHeight, window.screen.availWidth) * .25; 17 | return { 18 | type: 'mousedown', 19 | data: { 20 | x: pageX, 21 | y: pageY, 22 | scrollX, 23 | scrollY, 24 | documentSize: document.body.getBoundingClientRect(), 25 | size: imageSize, 26 | target: { 27 | innerText: target.innerText, 28 | tagName: target.tagName, 29 | }, 30 | url: location.href, 31 | } 32 | }; 33 | } 34 | 35 | function addIframeMouseDownListener(iframe) { 36 | try { 37 | function attachListener() { 38 | const iframeDoc = iframe.contentWindow.document; 39 | iframeDoc.addEventListener('mousedown', ({ pageX, pageY, target }) => { 40 | const iframePos = iframe.getBoundingClientRect(); 41 | const clickPosition = { x: pageX + iframePos.left, y: pageY + iframePos.top }; 42 | sendMessageToBg(createMouseDownRecord(clickPosition.x, clickPosition.y, window.scrollX, window.scrollY, target)); 43 | }); 44 | } 45 | iframe.addEventListener('load', attachListener); 46 | } catch (e) { /* Can cause SecurityError, which nothing can be do about */ } 47 | } 48 | 49 | [...document.getElementsByTagName('iframe')].forEach(addIframeMouseDownListener); 50 | 51 | const observer = new MutationObserver((mutationList) => { 52 | mutationList.forEach((mutation) => { 53 | [...mutation.addedNodes].filter((e) => e.nodeName == 'IFRAME').forEach(addIframeMouseDownListener); 54 | }); 55 | }); 56 | observer.observe(document, { attributes: false, subtree: true, childList: true }) 57 | -------------------------------------------------------------------------------- /src/content/page.js: -------------------------------------------------------------------------------- 1 | import { updateMeta } from './page/dom/seo.js'; 2 | import { main } from './page/dom/init/init.js'; 3 | import { attachOcrInfo } from './page/ocr/worker.js'; 4 | import { attachScrubs } from './page/dom/editor/editor.js'; 5 | import { toggleExportDropdown } from './page/dom/editor/ui.js'; 6 | import { saveWtc } from './page/export/wtc.js'; 7 | 8 | window.addEventListener('load', async () => { 9 | await main(); 10 | document.getElementById('exportMenu').addEventListener( 11 | 'click', 12 | () => toggleExportDropdown(document.getElementById('exportMenu')), 13 | ); 14 | document.getElementById('saveWtc').addEventListener('click', saveWtc); 15 | document.querySelector('[autofocus]').focus(); 16 | document.querySelector('h1').addEventListener('keyup', updateMeta); 17 | 18 | attachScrubs(document.querySelectorAll('.screenshot')); 19 | attachOcrInfo(document.querySelectorAll('.screenshot')); 20 | }); 21 | -------------------------------------------------------------------------------- /src/content/page/dom/editor/editor.js: -------------------------------------------------------------------------------- 1 | export function deleteStep(index = -1) { 2 | const step = document.querySelector(`[wtc-step-index="${index}"]`); 3 | step.remove(); 4 | } 5 | 6 | export function attachScrubs(screenshots = []) { 7 | for (const screenshot of screenshots) { 8 | const observer = new MutationObserver((mutations, observer) => { 9 | observer.disconnect(); 10 | const words = JSON.parse(mutations[0].target.getAttribute('wtc-ocr')); 11 | const overlay = screenshot.parentNode.querySelector('.scrub-overlay'); 12 | const parser = new DOMParser(); 13 | const sizeRatio = screenshot.clientHeight / screenshot.naturalHeight; 14 | const clientSize = { width: screenshot.clientWidth, height: screenshot.clientHeight }; 15 | for (const { word, box } of words) { 16 | const width = ((box.x1 - box.x0) * sizeRatio / clientSize.width) * 100; 17 | const height = ((box.y1 - box.y0) * sizeRatio / clientSize.height) * 100; 18 | const top = ((box.y0 * sizeRatio) / clientSize.height) * 100; 19 | const left = ((box.x0 * sizeRatio) / clientSize.width) * 100; 20 | const scrubElementHtml = ` 21 |
26 | `; 27 | const scrubElement = parser.parseFromString(scrubElementHtml, 'text/html').querySelector('.scrub-element'); 28 | scrubElement.addEventListener('click', () => { 29 | scrubElement.classList.toggle('scrubbed'); 30 | }); 31 | overlay.appendChild(scrubElement); 32 | } 33 | }); 34 | observer.observe(screenshot, { 35 | childList: false, 36 | subtree: false, 37 | attributes: true, 38 | attributeFilter: ['wtc-ocr'] 39 | }); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/content/page/dom/editor/ui.js: -------------------------------------------------------------------------------- 1 | import van from '../../../deps/mini-van-0.3.8.min.js'; 2 | import { saveHtml } from '../../export/html.js'; 3 | import { saveMarkdown } from '../../export/markdown.js'; 4 | import { savePdf } from '../../export/pdf.js'; 5 | 6 | const { div, button, li, ul } = van.tags; 7 | 8 | function Dropdown(child, target) { 9 | const { left, bottom } = target.getBoundingClientRect(); 10 | target.classList.add('bring-to-front'); 11 | return div( 12 | { class: 'dropdown', 'wtc-editor': 1 }, 13 | div( 14 | { style: `top: ${bottom}px; left: ${left}px; display: inline-block;` }, 15 | child 16 | ), 17 | ); 18 | } 19 | 20 | function Button(props, child) { 21 | return button( 22 | { ...props, class: 'wtc-button' }, 23 | child 24 | ); 25 | } 26 | 27 | let dropdown = null; 28 | export function toggleExportDropdown(anchor) { 29 | function cleanup() { 30 | dropdown.remove(); 31 | dropdown = null; 32 | } 33 | function cleanupAfter(func) { 34 | func(); 35 | cleanup(); 36 | } 37 | if (dropdown) { 38 | cleanup(); 39 | return; 40 | } 41 | 42 | van.add(document.body, 43 | Dropdown( 44 | li({ class: 'export-options' }, 45 | ul(Button({ onclick: () => cleanupAfter(savePdf) }, 'PDF')), 46 | ul(Button({ onclick: () => cleanupAfter(saveMarkdown) }, 'Markdown')), 47 | ul(Button({ onclick: () => cleanupAfter(saveHtml) }, 'HTML')), 48 | ), 49 | anchor, 50 | ), 51 | ); 52 | dropdown = document.getElementsByClassName('dropdown')[0]; 53 | } -------------------------------------------------------------------------------- /src/content/page/dom/init/init.js: -------------------------------------------------------------------------------- 1 | import { tagToName } from "../../tagToName.js"; 2 | import { deleteStep } from "../editor/editor.js"; 3 | import van from "../../../deps/mini-van-0.3.8.min.js"; 4 | import { BackNavigationStep, ScreenshotStep, StartingStep } from "./ui.js"; 5 | 6 | export async function loadSteps(sessionId = new URLSearchParams(window.location.href.split('?')[1]).get('s')) { 7 | async function tryFetchExtension() { 8 | try { 9 | return browser.runtime.sendMessage({ type: 'fetchImages', data: { session: sessionId } }); 10 | } catch (e) { 11 | console.error(e); 12 | return null; 13 | } 14 | } 15 | 16 | async function tryFetchLocal() { 17 | return localforage.getItem(sessionId); 18 | } 19 | 20 | return (await tryFetchExtension()) || (await tryFetchLocal()); 21 | } 22 | 23 | function setupDocument(steps = []) { 24 | const content = document.querySelector('.steps'); 25 | steps.forEach((step) => van.add(content, step)); 26 | 27 | [...content.querySelectorAll('.delete-button')].forEach((deleteButton, index) => { 28 | deleteButton.addEventListener('click', () => deleteStep(index + 1)); 29 | }); 30 | 31 | document.querySelectorAll('textarea').forEach((textarea) => { 32 | textarea.style.height = `${textarea.scrollHeight}px`; 33 | textarea.addEventListener('input', (e) => { 34 | const element = e.target; 35 | element.innerText = element.value; 36 | element.style.height = 0; 37 | element.style.height = `${element.scrollHeight}px`; 38 | }); 39 | }); 40 | const time = document.querySelector('footer time'); 41 | time.setAttribute('datetime', new Date().toISOString()); 42 | document.querySelector('[property="author:modified_time"]').setAttribute('content', new Date().toISOString()); 43 | time.innerText = new Date().toDateString(); 44 | document.querySelectorAll('[wtc-editor]').forEach((element) => element.classList.remove('hidden')); 45 | document.querySelectorAll('[wtc-editable]').forEach((element) => element.setAttribute('contenteditable', true)); 46 | } 47 | 48 | export async function main() { 49 | const steps = await loadSteps(); 50 | if (steps.length === 0) { 51 | return; 52 | } 53 | function createStep(step, index) { 54 | return step.type === 'mousedown' 55 | ? ScreenshotStep(step, index) 56 | : BackNavigationStep({ url: step.url, index }); 57 | } 58 | const documentSteps = [] 59 | if (steps[0].url) { 60 | documentSteps.push(StartingStep(steps[0])); 61 | } 62 | 63 | setupDocument([...documentSteps, ...steps.map(createStep)]); 64 | } 65 | -------------------------------------------------------------------------------- /src/content/page/dom/init/ui.js: -------------------------------------------------------------------------------- 1 | import van from "../../../deps/mini-van-0.3.8.min.js"; 2 | import { tagToName } from "../../tagToName.js"; 3 | 4 | const { div, p, span, textarea, picture, img, button, a } = van.tags; 5 | 6 | function constructCursorPosition(offset, size) { 7 | const offsetPercent = { 8 | left: offset.left / size * 100, 9 | top: offset.top / size * 100, 10 | bottom: offset.bottom / size * 100, 11 | right: offset.right / size * 100, 12 | } 13 | 14 | let result = ''; 15 | if (offsetPercent.left) result += `left: -${offsetPercent.left}%;`; 16 | if (offsetPercent.top) result += `top: -${offsetPercent.top}%;`; 17 | if (offsetPercent.bottom) result += `bottom: -${offsetPercent.bottom}%;`; 18 | if (offsetPercent.right) result += `right: -${offsetPercent.right}%;`; 19 | return result; 20 | } 21 | 22 | function StepDescription(child) { 23 | return p({ class: 'step-description' }, 24 | span({ class: 'text-content' }, 25 | span({ class: 'index' }), 26 | child, 27 | ), 28 | button({ class: 'text-button delete-button', 'wtc-editor': 1 }, 'Remove step'), 29 | ); 30 | } 31 | 32 | export function StartingStep({ url }) { 33 | return div({ class: 'step', 'wtc-step-index': 1 }, 34 | StepDescription(span({ class: 'content' }, ['Visit ', a({ href: url }, url), '.'])) 35 | ); 36 | } 37 | 38 | export function BackNavigationStep({ url, index }) { 39 | return div({ class: 'step', 'wtc-step-index': index }, 40 | StepDescription(span({ class: 'content' }, ['Go back to ', a({ href: url }, url), '.'])) 41 | ); 42 | } 43 | 44 | export function ScreenshotStep({ image, offset, size, target }, index) { 45 | const actionDescription = tagToName[target.tagName] ? `${tagToName[target.tagName]}` : ''; 46 | 47 | return div({ class: 'step', 'wtc-step-index': index + 2 }, 48 | StepDescription( 49 | textarea({ class: 'content', 'wtc-textarea': 0 }, 50 | `Click "${target.innerText}" ${actionDescription}.` 51 | ), 52 | ), 53 | div({ class: 'step-image' }, 54 | picture( 55 | img({ class: 'screenshot', src: image }), 56 | div({ class: 'scrub-overlay' }), 57 | div({ class: 'loading-overlay' }), 58 | img({ class: 'cursor', style: constructCursorPosition(offset, size), src: cursorPng }), 59 | ), 60 | ), 61 | ); 62 | } 63 | 64 | const cursorPng = 'data:image/webp;base64,UklGRhQPAABXRUJQVlA4TAcPAAAv/8A/ENKA0DaSIMnhD3t+5rp/CUTEBHgMcjbp7DwM9ijVxvUpjb7Ya/rW/B9tHu1uSWxU/kFf62uxZK/tz2HPhutcqjDlNev9fnTHDyrv4akMhpvZRM4eyZJku26b3v+y7US4APHIJyTSYmxKMIK2bXP+0F5nmEIStW3HG8335Tv503Mmf2rbtladrsLatrsbq7a5tm3bSlJzbE+dlIkkSJIcKYpEMzPA3YrWnfmlJUmS1QiKvP+t95UNgspfSb3ALMx2lzkk//+/Ls36T+jO60577Lj7/P74YZ7obrulu1Z2K7LAnWz5SdhBN6xPdoNJiCS2kRxJkta3OdzMbG9ldbn8zsZkAIQExjCJ4BUlNDDAImH+s0mCU1Jc7L/z/nOsNwM0XCcRsDBDWsiAd29QAkJ+40c6LbD598sdwiwh+OXvQTMZBGIlCnAoCIBjx2Nq2OJyR1hQ+4tdGniCPaIGh3BzQx4PymDDu3ls2UNZowwvlIBdxygwKWDzd22s34tiHJ4CXQaAMtH0croqEecMEi+13n7h5CkVzHK9qhI3LPzL87NOuAmDmUm2Qs0bNjdLRESYNHOOsFpxzA9yuNE7kOcFbxEgrFqd/7xGsWfPsVhTC281oIN6bB99QggnZrhD2IhOZnEV6g9gBLGBYDWknW2CReoLhhHC/mpOHBIGqR8Ywq/wR2RIsk4AN+aTfnpoQosMEfz5/fw7jp+z43pYJ0ma7Kqyj28nLgOEDqfYdS5OiWFnADUVIgh1CTR6CRKGMtTzhz143BW7DFwYgh2AV4yv8yh1Enj4jkqMuZo/pF8vEn2dZ5KJo3WQpJTzNbaxxTTNcATN1RUMk89Y2VpjE+eUI9kyPoFwfiBcLGc46fpj2+v80s4K/JUtfhLZ7s/AiKns2wWHTCFXgcDLXaQzxFH27fqJcZtAIjm3kMnRA1+wwEbcSWCYs9yi6EMiDYI13JUl0rjRqEBgUy6ycS38m8waVq1hRBK4XDmwjUkkgQ0qIt/ZXHZ9IwmsKdBhIethgDBKwXOjKvcgsuhC9z4balUiiKOcazNNqaC5YZ8P1iWn5ogggUaATFXG/z5JzGLMzXt3kgte8VQKbwL0Wc/4iElR5y4UmYkFX7CBQQN9KHjGDyPDtOgCu1EMbE/7XngaqBwfkcpt+DaPH67Arvzi7c3XPdKEqgYKHSsq1hAJNfcmYlbJtkqnKBWDKuxwuQ+D0AI7VGh6m0MSOKhWCxZ8iZ6FQxSBnfqw0nrQgWWlQIte/4NO0NyvaNhrfSigVwn+8INfZU6YuWt/78YfTgIqLGsSF+xKI47+Edi5DzoOG2/SES9Q2ys1wdY1AsILFOAbf2MpiBfPul4RtL2TYkCwQAkKhaGtLITgUdPLiaSPCOxQK1CG1I62N9LqeTkRtr3jF0GgEIUn0Pb2BFRzRtN7Z1j5sxSV9+lNBxyVvBB/hq5BoyCBYnw6qaa3nyogIPQHHQgEChL+0fTy+K4A6PBXALagCZQk9LOpAPbevq7B0QrAH5FmUYr4aSqCf21d0wxVtfCpcJbl3ZuCMFQ2RRTYKwAeFczCvJtuhhxQthxKQ+cKwEpp73N+3wgDosPQdoPkSQu17itPoDhP5ldApAlsBZ7cRj4u733Os+XLC4+NwICj2BkFOloOuKO/TfdKpD47/yhrl/jWWx4w8C1qG1RFyhsqFCjS+zO8VG5wDEEIAqXNa5apSGdDmHgv37McOIhDqLNQoRFv2OcsPXr8HajCwBcoVQQNwSLzhpXlCtxwaRQo1t5w2SCh7KAaLtMwLKhaHoYaWqZgVRATCTx141eeQLmeBBoKTUYqB8mBJlbhZ8GK0FAZS1K58YTw0legVqBkqfVhw4FRIUBMIUzCgEDRvof1+V0GIvb0QYKrpvt9EBBeZig1P9MFLuEFyvbti1/8eJaAsvR/FtpZuOj7cFJaYh4B5xbmBFXOc/tm+l/5s0gYHw72hJml++vDJ/oN5gKDTMPPihed/dEJPROH4PiKtqd6Jg7fKstQHvjttqgiikD5iGrvm+345s0fZH856J8B/BlO9oTlQOhKwarQCVAua8N5ZCCMg/TYlRlBxN321zzjgPd3GGcGBPkK9HgbJNdsOZ003BDMry1LsOlQFNBcOLAJxNAG0jvO0SKnLaSSFD0HYthaWGYeMXhzOZgQCCKTtvCJdQyM9rPISRDF9tShLgT3OHFgnlEEscXp7wjU27PcWbhtHSQvIz1N/G08S6yTvCF6eOfO3ClNAw/twwrDw+AwEBaUhouQe1xptiDDsQPljONhRwXgpoNY28ZAcB4628MIw3UnZca+LGcgTwczXP5npMGNO7NIiRDRnZgkT/4ZHicb52Yk7c10yv+5hSULKVBnAo2DuectUNlTD8oqyIQKf923KN+CuNR/CYhAKJlacDD9KWhIBQIHfbfWB+Ys1dEsOBVC/+c6D4H/DaysGne06Bvm31CUAlkukDso/LvBkc3UADUV5GK45oTX468WJ24S4BAIJi7XnEzyf82vWAnoSMYxjHjERtpwASsZsHtTKxwAnFSVeyZDkAu+D4FPTBR+ssExmthdr1Qon2C/J6AxGzS5SwwP/qhzB74TdMPxCfUJSAiVjYsjA/VzTmCqRRbPDCdewwM4J3iqMMb3dDxuR5E/ZtbvCZCnA4W7yGI+JwGpLmkx0iGme5XhPycZqVviTIegtwux0x1uROIxidrbbwDYCbDng2kDqwAh/qWm2OQDo+tQBkKKm5weh4R3H7hBEpM91RuTD8rcn1mMU22ul3D5EP5yda9EpDpjBOVDqG4gPDXcinWhAtJdAyxKU02xM6CPgRIaUi1RCcHpIm8G4l1OKW8+0c+ii7oT4uIM5gkbMCSEPte+kP8GehJCr+Fg00BTQmh2szYRN6BJCFrXxsLWQyTk41rgkzQgSghiF2i4sBN+QuC7QHMRGVtfXfm/ib/LO/6JjvzlrsDl7sOVu13cRX/euIuQi7sxBY67x9/uQkN0wknOtpfUUTLedleCBop5Od52dzes3DX+fheYw+93w+Qcfb8rkqPvd5eEEH/HPu6CP6Dxj7sZ/rirf4BxdxP/sY+7xG9OzFO/CQpHuuEndszGO+4ak7vKQB79uHu2gJF5F+Eij8f1u6AuNO8Gdjbg9JaxJ3ibvN8Vdn9sLsepK3kmLXXCgzL8eZeA4c+7Dc67pjNpv+vgvPufoP3ukY+uu6D8mOMusAGMrruBPGWnu0VheN0VkFww5YBxY3tZ4inH3TnsuDvxdZfgpwLhMNCbseoiSCqw2HG3/iXWXeMyC5HH3TMw+nUXeXh73Umexh938ww87ipTgMx1d4VKO+7um5vxx11+Y3IQyjfu9nDXXafcj7uev+4+9nDj7vPWiAX2XRA93LwLJfbdAIk778bbTtNKUpQkiNodM7jZtp13h8kkYF5n3h2uMOsgdQdpbEDKjrkPnDEB55p3C/twZ8Yp7B/Uz7sGLwXjcrARt6YGzk84HQLlEFht3r0Jxn7yBoo4A2nTUOy9C+67yZpyI827SUiWe9znCPddZTfPgAS+u4NTUQPNu4tPpucA2MOJY8aZd/nIdaED3c+7je5Pksw8f0LL3XdckHG/YBFhakdYP+86fYD8ffc5yzbv/gvjmS9K10i+hLZbKCniu4EfKyXiIhR+q+Hw5ShJzDUkPP2fRaDudVcQ9L9ChJXxnWEEJldSGOvuYmNhwhFmGWGY9l1CmrqaeRrWXfKYpUTSSopdEUreqWHdLSQWtJQ8Bt81+Ifl9T3LCSv4A/Dd82lYgl1Za8okBHwXlTsiydjYd9GEyHzvfTchJLWSMCfi5r6riEMrft1VaM/SIjDiu6vQxiid7YbLxtcGvsuoXGnxV0VVcvw/PFRsYcfYyKyPxHfb/r2Nweh7xN54jeuuu8g27ITe3Ea4R3z34Sh63X24b+U70AFSQ74LvxWvu/BnOy/WoJDN6N/iNq6Y70YfbWg8UjjsFTqh2CPWAb6p8UxU+BwyXFvYP/rFxgrwH5UKfZfyt9R1l/If8+3dVsNfAbFdVBGcqJjv1nsNfqu76bv2ivmufc8aRFzMdy9N/fHdu2K+e4mrxHcxz84e+i6mt2bfxfNJYtB3s4ilnD/ou5nEZ+W+q9ktpDb6qt139ZxPEmK+u0ljLOKGzH7FfHefNz7e8AFjECyhPv51rhU+o64XYoNhFw50+193OwVh3+0GmvFdz7ywO19X3RH3XV+joMZ99++5ReG79aHgP7RKgwdgzucV/CLO3TbOunD00QafsZi1ChVWV1CcYthldZTQ9L1Ho7BRqTh4BDjtKyrWkezvqLs97wo6ZtXBMxwiJZ67g8DOGmkPfO15d/wI1R4cEveM3CXYxSwh7xLcAbN6oZeRu4UUZtF2soiwTmo0yzr6beSuoeLM+ABkB31VxARZknfNl8ithOckIC93D+XbzruHhxnXWetOIGA2I14yvyzvIlSbDceEQkloUd5FzKPTVrpCGjJzNzG4zbybMLE5lgifBBFbSx6FJZzM3FV40G5skd43ajzPWOQLqxZzd5EILzckI9ZH6M2UMBGCLE3l8bhMZDYpDJlEsDJFAiuKDRyuAuSYOVycdxmTGM1WJQJhfC+QCw43na/Nu402nJyRXSw/iDBCy8njkKDkVSJ3HdtM0wzvBZuEhkUj9u8aede9KENiNi6M6SuVuw8vJlRiClrr0OdExveLo5Xy7qMfox5kTIUOey8XpJZfTGNEQ7mIghfkXSgspWgwnkQ4Xe//cUDrREhhIXzZK5+7EScIJvrooRktMsR/ybvxPn4ZBPlZP+9G9vAxNLshMILZHbuTA0J7kzwT7N7y7iQIrEe5S5neT96lzOAC6lTaXl5j2EferdRhA+xZ7lqqq89dy3teodi93L3QaeSs4ty9tMCAOHsobkJnmuQW6czA5GahmXbzmDJmK/vCzgLlPOVyvXlX08NJLXBKP3HvPkfPnuD/KWDj9Xl3s0ExLPC+5y7nDvl8xvmyvMvhwz3xQhE4iNztlGNgEx53ZSOns0MDj7FHdCwR7A1yH1N8SKOZVf4WyF3//0kGAViAC44qfT4AhDiGMAnnJcXU088CIf6zSZxTkmTOfXLCz4OdO/3UU3y9YGKKlFBrTy8TAA=='; -------------------------------------------------------------------------------- /src/content/page/dom/seo.js: -------------------------------------------------------------------------------- 1 | export function updateMeta() { 2 | const title = document.querySelector('h1'); 3 | // Firefox adds
to contenteditable h1's for some reason 4 | // which breaks regexps. Get rid of them: 5 | const titleText = title.innerHTML.replaceAll('
', '').replace(/:$/, ''); 6 | document.querySelector('title').innerText = titleText; 7 | document.querySelector('[property="og:title"]').setAttribute('content', titleText); 8 | document.querySelector('[name="description"]').setAttribute( 9 | 'content', 10 | `Step-by-step guide ${titleText.replace('What to click', '')}` 11 | ); 12 | document.querySelector('[property="og:description"]').setAttribute( 13 | 'content', 14 | `Step-by-step guide ${titleText.replace('What to click', '')}` 15 | ); 16 | } -------------------------------------------------------------------------------- /src/content/page/export/common/download.js: -------------------------------------------------------------------------------- 1 | export function download(filename, data, options = { type: 'text/html' }) { 2 | const blob = new Blob([data], options); 3 | const url = URL.createObjectURL(blob); 4 | const el = document.createElement('a'); 5 | el.href = url; 6 | el.download = filename; 7 | document.body.appendChild(el); 8 | el.click(); 9 | document.body.removeChild(el); 10 | URL.revokeObjectURL(url); 11 | } 12 | 13 | export function downloadURI(uri, name) { 14 | const link = document.createElement("a"); 15 | link.download = name; 16 | link.href = uri; 17 | document.body.appendChild(link); 18 | link.click(); 19 | document.body.removeChild(link); 20 | link.remove(); 21 | } -------------------------------------------------------------------------------- /src/content/page/export/common/scrubs.js: -------------------------------------------------------------------------------- 1 | import { loadSteps } from "../../dom/init/init.js"; 2 | 3 | export function applyScrubs(screenshot) { 4 | const canvas = document.createElement('canvas'); 5 | canvas.style = "width: 100%"; 6 | const context = canvas.getContext('2d'); 7 | canvas.width = screenshot.naturalWidth; 8 | canvas.height = screenshot.naturalHeight; 9 | context.drawImage(screenshot, 0, 0, screenshot.naturalWidth, screenshot.naturalHeight); 10 | const scrubs = screenshot.parentNode.querySelectorAll('.scrub-overlay>.scrubbed'); 11 | for (const scrub of scrubs) { 12 | const { box } = JSON.parse(decodeURIComponent(scrub.getAttribute('wtc-word'))); 13 | const { x0, y0, x1, y1 } = box; 14 | context.beginPath(); 15 | context.rect(x0, y0, x1 - x0, y1 - y0); 16 | context.fill(); 17 | } 18 | screenshot.src = canvas.toDataURL('image/webp'); 19 | } 20 | 21 | export async function removeScrubs() { 22 | const steps = await loadSteps(); 23 | const screenshots = document.querySelectorAll('.step .screenshot'); 24 | screenshots.forEach((screenshot) => { 25 | const stepIndex = parseInt(screenshot.parentElement.parentElement.parentElement.getAttribute('wtc-step-index'), 10) - 2; 26 | screenshot.src = steps[stepIndex].image; 27 | }); 28 | } -------------------------------------------------------------------------------- /src/content/page/export/html.js: -------------------------------------------------------------------------------- 1 | import { downloadURI } from "./common/download.js"; 2 | import { applyScrubs, removeScrubs } from "./common/scrubs.js"; 3 | 4 | export async function saveHtml() { 5 | document.querySelectorAll('.screenshot').forEach(applyScrubs); 6 | const pageHtml = document.querySelector('html').innerHTML; 7 | const documentToExport = new DOMParser().parseFromString(pageHtml, 'text/html'); 8 | documentToExport.querySelectorAll('[wtc-editor]').forEach((element) => element.classList.add('hidden')); 9 | documentToExport.querySelectorAll('.scrub-overlay').forEach((element) => element.remove()); 10 | documentToExport.querySelectorAll('[wtc-ocr]').forEach((element) => element.removeAttribute('wtc-ocr')); 11 | documentToExport.querySelectorAll('[wtc-editable]').forEach((element) => element.removeAttribute('contenteditable')); 12 | documentToExport.querySelectorAll('[wtc-textarea]').forEach((textarea) => { 13 | textarea.style = ''; 14 | const span = new DOMParser().parseFromString( 15 | textarea.outerHTML.replace('$', 'gm'), ''), 16 | 'text/html' 17 | ).querySelector('span'); 18 | textarea.replaceWith(span); 19 | }); 20 | 21 | const htmlContent = documentToExport.querySelector('html').innerHTML 22 | .replace(/</g, '<') 23 | .replace(/>/g, '>'); 24 | const page = ` 25 | 26 | ${encodeURIComponent(htmlContent)} 27 | `; 28 | downloadURI(`data:text/html,${page}`, `What to click ${new Date().toDateString()}.html`); 29 | await removeScrubs(); 30 | } -------------------------------------------------------------------------------- /src/content/page/export/json.js: -------------------------------------------------------------------------------- 1 | import { applyScrubs, removeScrubs } from "./common/scrubs.js"; 2 | 3 | export async function asJson() { 4 | document.querySelectorAll('.screenshot').forEach(applyScrubs); 5 | const title = document.querySelector('h1').innerText; 6 | const steps = [...document.querySelectorAll('.step')].map((stepElement) => { 7 | const description = stepElement.querySelector('.content').innerHTML; 8 | const screenshot = (stepElement.querySelector('.screenshot') || {}).src || null; 9 | return { description, screenshot }; 10 | }); 11 | 12 | await removeScrubs(); 13 | return { title, steps }; 14 | } 15 | -------------------------------------------------------------------------------- /src/content/page/export/markdown.js: -------------------------------------------------------------------------------- 1 | import { download } from "./common/download.js"; 2 | import { applyScrubs, removeScrubs } from "./common/scrubs.js"; 3 | 4 | export async function saveMarkdown() { 5 | document.querySelectorAll('.screenshot').forEach(applyScrubs); 6 | const title = document.querySelector('h1').innerText; 7 | var markdown = `# ${title}\n\n`; 8 | document.querySelectorAll('.step').forEach((el, index) => { 9 | let image = el.querySelector('.step-image .screenshot'); 10 | let description = el.querySelector('.step-description .content'); 11 | 12 | markdown += `${index + 1}. ${description.textContent}` 13 | if (image != undefined && image != null) { 14 | markdown += `\n ![${description.textContent.split(`\n`)[0] + '...'}](${image.src})\n\n`; 15 | } else { 16 | markdown += `\n\n`; 17 | } 18 | }) 19 | 20 | download(`What to click ${new Date().toDateString()}.md`, markdown, { type: 'text/markdown' }); 21 | await removeScrubs(); 22 | } 23 | -------------------------------------------------------------------------------- /src/content/page/export/pdf.js: -------------------------------------------------------------------------------- 1 | import { applyScrubs, removeScrubs } from "./common/scrubs.js"; 2 | 3 | export async function savePdf() { 4 | document.querySelectorAll('.screenshot').forEach(applyScrubs); 5 | document.querySelectorAll('[wtc-editor]').forEach((element) => element.classList.add('hidden')); 6 | const textareas = []; 7 | document.querySelectorAll('[wtc-textarea]').forEach((textarea) => { 8 | textareas.push(textarea); 9 | textarea.style = ''; 10 | const span = new DOMParser().parseFromString( 11 | textarea.outerHTML.replace('$', 'gm'), ''), 12 | 'text/html' 13 | ).querySelector('span'); 14 | textarea.replaceWith(span); 15 | }); 16 | await browser.runtime.sendMessage({ type: 'savePdf' }); 17 | document.querySelectorAll('[wtc-textarea]').forEach((span, index) => { 18 | const textarea = textareas[index]; 19 | span.replaceWith(textarea); 20 | textarea.style.height = `${textarea.scrollHeight}px`; 21 | }); 22 | document.querySelectorAll('[wtc-editor]').forEach((element) => element.classList.remove('hidden')); 23 | await removeScrubs(); 24 | } -------------------------------------------------------------------------------- /src/content/page/export/wtc.js: -------------------------------------------------------------------------------- 1 | import { downloadURI } from "./common/download.js"; 2 | 3 | export function saveWtc() { 4 | const pageHtml = document.querySelector('html').innerHTML; 5 | const documentToExport = new DOMParser().parseFromString(pageHtml, 'text/html'); 6 | documentToExport.querySelectorAll('[wtc-editor]').forEach((element) => element.classList.add('hidden')); 7 | documentToExport.querySelectorAll('[wtc-editable]').forEach((element) => element.removeAttribute('contenteditable')); 8 | documentToExport.querySelectorAll('[wtc-textarea]').forEach((textarea) => { 9 | textarea.style = ''; 10 | const span = new DOMParser().parseFromString( 11 | textarea.outerHTML.replace('$', 'gm'), ''), 12 | 'text/html' 13 | ).querySelector('span'); 14 | textarea.replaceWith(span); 15 | }); 16 | const htmlContent = documentToExport.querySelector('html').innerHTML 17 | .replace(/</g, '<') 18 | .replace(/>/g, '>'); 19 | const page = ` 20 | 21 | ${encodeURIComponent(htmlContent)} 22 | `; 23 | downloadURI(`data:text/html,${page}`, `What to click ${new Date().toDateString()}.wtc`); 24 | } 25 | 26 | -------------------------------------------------------------------------------- /src/content/page/ocr/worker.js: -------------------------------------------------------------------------------- 1 | import * as ocr from '../../deps/tesseract@4.0.5.min.js'; 2 | 3 | let worker; 4 | 5 | async function initWorker(root = window.location.origin) { 6 | const w = await Tesseract.createWorker({ 7 | workerPath: `${root}/content/deps/worker@4.0.5.min.js`, 8 | workerBlobURL: false, 9 | langPath: `${root}/content/deps/`, 10 | corePath: `${root}/content/deps/tesseract-core-simd.js`, 11 | tessedit_create_hocr: '0', 12 | tessedit_create_tsv: '0', 13 | tessedit_create_box: '0', 14 | tessedit_create_unlv: '0', 15 | tessedit_create_osd: '0', 16 | errorHandler: e => console.error(e) 17 | }); 18 | await w.loadLanguage('eng-fast'); 19 | await w.initialize('eng-fast'); 20 | worker = w; 21 | return w; 22 | } 23 | 24 | async function recognizeWords(element) { 25 | const result = await worker.recognize(element); 26 | return result.data.paragraphs.map(({ lines }) => { 27 | return lines.map((line) => line.words.map((word) => { 28 | return { 29 | word: word.choices[0], 30 | box: word.bbox, 31 | }; 32 | })).flat(); 33 | }).flat(); 34 | } 35 | 36 | 37 | export async function attachOcrInfo(screenshots) { 38 | document.querySelector('.ocr-loading-indicator').classList.toggle('hidden'); 39 | if (worker == null) { 40 | await initWorker(); 41 | } 42 | for (const screenshot of screenshots) { 43 | const overlay = screenshot.parentNode.querySelector('.loading-overlay'); 44 | overlay.classList.toggle('loading'); 45 | const words = await recognizeWords(screenshot); 46 | const serialized = JSON.stringify(words); 47 | screenshot.setAttribute('wtc-ocr', serialized); 48 | overlay.classList.toggle('loading'); 49 | } 50 | document.querySelector('.ocr-loading-indicator').classList.toggle('hidden'); 51 | } -------------------------------------------------------------------------------- /src/content/page/tagToName.js: -------------------------------------------------------------------------------- 1 | export const tagToName = { 2 | 'BUTTON': 'button', 3 | 'A': 'link', 4 | 'INPUT': 'input field', 5 | }; -------------------------------------------------------------------------------- /src/icons/record.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 37 | 39 | 42 | 45 | 49 | 53 | 54 | 55 | 60 | 61 | -------------------------------------------------------------------------------- /src/icons/stop.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 38 | 39 | 68 | -------------------------------------------------------------------------------- /src/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "manifest_version": 2, 3 | "name": "What-to-click", 4 | "version": "1.12.6", 5 | "description": "Fully offline, AI-powered how-to documentation creator.", 6 | "icons": { 7 | "48": "icons/record.svg" 8 | }, 9 | "permissions": [ 10 | "", 11 | "activeTab", 12 | "tabs", 13 | "webNavigation" 14 | ], 15 | "browser_action": { 16 | "default_icon": "icons/record.svg", 17 | "default_title": "Record what to click" 18 | }, 19 | "background": { 20 | "page": "background/background.html", 21 | "persistent": false 22 | }, 23 | "content_scripts": [ 24 | { 25 | "matches": [ 26 | "" 27 | ], 28 | "js": [ 29 | "content/index.js" 30 | ] 31 | } 32 | ], 33 | "web_accessible_resources": [ 34 | "content/page.html" 35 | ], 36 | "commands": { 37 | "_execute_browser_action": { 38 | "suggested_key": { 39 | "default": "Alt+R" 40 | } 41 | } 42 | }, 43 | "browser_specific_settings": { 44 | "gecko": { 45 | "id": "{7feef224-a737-4d04-b0c1-ea47d4cad70a}" 46 | } 47 | } 48 | } --------------------------------------------------------------------------------