Coder Social home page Coder Social logo

lofihippo / wombo-dream-web-resizer Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 8 KB

Tampermonkey boilerplate script that resizes the image in the preview as a 16x9 resolution aspect ratio instead of being smushed together assuming it's a phone resolution on the web.

License: The Unlicense

wombo-dream-web-resizer's Introduction

# Wombo-Dream-Web-Resizer

Tampermonkey boilerplate script that resizes the image in the preview as a 16x9 resolution aspect ratio instead of being smushed together assuming it's a phone resolution on the web.

Without Script:

image

With Script:

image

To run, download the Firefox extension Tampermonkey (or comporable alternative that allows for user scripting) Location on Firefox Add-Ons: https://addons.mozilla.org/en-US/firefox/addon/tampermonkey/

Once installed in Firefox, click on the Tampermonkey extension icon, and click on "Create a new script..."

Once you have the Editor open, paste the script: (You can also copy the script from the Nekobin here https://nekobin.com/gewibalote or in the userscript.txt file in this GitHub repository)

// ==UserScript==
// @name        DreamAI Image Resizer
// @namespace   https://www.dream.ai/
// @description This script resizes images to their natural dimensions on DreamAI websites.
// @match     *://*.dream.ai/listing*
// @version     1.0
// @grant       none
// @run-at      document-start
// ==/UserScript==

(function() {
    let aspectRatio = 1920 / 1080;

    // function to resize the trading_card image
    function resizeImage() {
        let img = document.querySelector('img[alt="trading_card"]');
        if (img) {
            let container = img.parentElement; // assuming image is wrapped in a container
            container.style.maxWidth = '100%';
            container.style.height = (container.offsetWidth / aspectRatio) + 'px';
        }
    }

    // create a MutationObserver instance to watch for changes in the DOM
    let observer = new MutationObserver(function(mutations) {
        mutations.forEach(function(mutation) {
            if (mutation.type === 'childList') {
                resizeImage();
            }
        });
    });

    // start observing the document with the configured parameters
    observer.observe(document.body, { attributes: true, childList: true, subtree: true });
})();

Future suggestions or possible changes

This is just a boilerplate script that shows it can be resized. I'm not experienced enough with scripting/css to accurately change it so the bounding box around the resized image, is properly scaled up to make the overall image shown larger.

If someone wants to modify it and also support other aspect ratios and image sizes than 16x9 and 1920x1080p, that would be awesome.

wombo-dream-web-resizer's People

Contributors

lofihippo avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.