commit c4c0be94b032c734b5275a5b45ec6e68841817ba Author: Martin Matous Date: Thu Mar 31 20:59:21 2022 +0200 initial commit Signed-off-by: Martin Matous diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ced4fa8 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +node_modules +package-lock.json +web-ext-artifacts diff --git a/.web-extension-id b/.web-extension-id new file mode 100644 index 0000000..e2aa1b7 --- /dev/null +++ b/.web-extension-id @@ -0,0 +1,3 @@ +# This file was created by https://github.com/mozilla/web-ext +# Your auto-generated extension ID for addons.mozilla.org is: +{3bec3738-3f4b-4517-8396-59b3b5e6f6f7} \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..68a49da --- /dev/null +++ b/LICENSE @@ -0,0 +1,24 @@ +This is free and unencumbered software released into the public domain. + +Anyone is free to copy, modify, publish, use, compile, sell, or +distribute this software, either in source code form or as a compiled +binary, for any purpose, commercial or non-commercial, and by any +means. + +In jurisdictions that recognize copyright laws, the author or authors +of this software dedicate any and all copyright interest in the +software to the public domain. We make this dedication for the benefit +of the public at large and to the detriment of our heirs and +successors. We intend this dedication to be an overt act of +relinquishment in perpetuity of all present and future rights to this +software under copyright law. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +For more information, please refer to diff --git a/README.md b/README.md new file mode 100644 index 0000000..48660be --- /dev/null +++ b/README.md @@ -0,0 +1,21 @@ +# unfdom + +Fix *.fandom.com gallery browsing. + +Fandom's lightbox unnecessarily crops +images even on high enough screens while middle-click and opening in a new tab +redirect back to the page without opening the image. +Unfdom changes the latter and makes images open in a new tab. + +## Build + +``` +web-ext build +web-ext sign --api-key= --api-secret= +``` + +Both key and secret can be found after registering at http://addons.mozilla.org/. + +## License + +[The Unlicense](LICENSE) diff --git a/manifest.json b/manifest.json new file mode 100644 index 0000000..5bc3fc5 --- /dev/null +++ b/manifest.json @@ -0,0 +1,17 @@ +{ + + "manifest_version": 2, + "name": "unfdom", + "version": "1.0", + "description": "Fix *.fandom.com gallery browsing", + "author": "Martin Matouš", + "homepage_url": "https://codeberg.org/mmatous/unfdom", + + "content_scripts": [ + { + "matches": ["https://*.fandom.com/*"], + "js": ["unf.js"] + } + ] + +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..3ab412f --- /dev/null +++ b/package.json @@ -0,0 +1,5 @@ +{ + "dependencies": { + "web-ext": "^6.8.0" + } +} diff --git a/unf.js b/unf.js new file mode 100644 index 0000000..59ff4ce --- /dev/null +++ b/unf.js @@ -0,0 +1,9 @@ + +const galleryElements = document.body.querySelectorAll('a.image.lightbox') +for (const elem of galleryElements) { + const thumb = elem.querySelector('img.thumbimage.lazyload') + const src = thumb.getAttribute('data-src') + const needle = '/latest' + const fullImage = src.substring(0, src.indexOf(needle) + needle.length) + elem.setAttribute('href', fullImage) +}