bijij / ViewImage

Extension to re-implement the "View Image" and "Search by image" buttons into google images.
MIT License
780 stars 106 forks source link

Incorrect Labels on 3.2.0 #198

Closed needforsuv closed 4 years ago

needforsuv commented 4 years ago

It works, but some of the labels are messed up

Image of mislabeled buttons

bijij commented 4 years ago

This doesn't happen to me. I'll take a look into it but I'm not sure I can do much.

Can you send a snippet of the surrounding html? Need in particular the CSS classes.

needforsuv commented 4 years ago

https://imgur.com/a/m0uxPmD

I see no difference in the classes between 3.2.0 and 3.0.4

but in js source code I found this:

3.0.4

function addSearchImgButton(container, image, redesign) {

    var link = redesign ? container.querySelector('.irc_ft > a.irc_help') : container.querySelector('.irc_dsh > a.irc_hol');

    // Create the search by image button
    var searchImgButton = link.cloneNode(true);
    searchImgButton.classList.add('vi_ext_addon');

    // Set the more sizes button text
    var searchImgButtonText = searchImgButton.querySelector(redesign ? 'span' : '.irc_ho');
    if (options['manually-set-button-text']) {
        searchImgButtonText.innerText = options['button-text-search-by-image'];
    } else {
        localiseObject(searchImgButtonText, '__MSG_searchImg__');
    }

    // Set the search by image button url
    searchImgButton.href = '/searchbyimage?image_url=' + image.src;

    // Set additional options
    if (options['open-search-by-in-new-tab']) {
        searchImgButton.setAttribute('target', '_blank');
    }

    // Place the more sizes button
    link.parentElement.insertBefore(searchImgButton, link);
    link.parentElement.insertBefore(link, searchImgButton);

}

3.2.0

function addSearchImageButton(container, imageURL, version) {

    var link;
    switch (version) {
    case VERSIONS.FEB18:
        link = container.querySelector('.irc_dsh > a.irc_hol');
        break;
    case VERSIONS.JUL19:
        link = container.querySelector('.irc_ft > a.irc_help');
        break;
    case VERSIONS.OCT19:
        link = container.querySelector('.PvkmDc');
        break;
    }

    // Create the search by image button
    var searchImageButton = link.cloneNode(true);
    searchImageButton.classList.add('vi_ext_addon');

    // Set the more sizes button text
    var searchImageButtonText;
    switch (version) {
    case VERSIONS.FEB18:
        searchImageButtonText = container.querySelector('span');
        break;
    case VERSIONS.JUL19:
        searchImageButtonText = container.querySelector('.irc_ho');
        break;
    case VERSIONS.OCT19:
        searchImageButtonText = searchImageButton;
        break;
    }

    if (options['manually-set-button-text']) {
        searchImageButtonText.innerText = options['button-text-search-by-image'];
    } else {
        localiseObject(searchImageButtonText, '__MSG_searchImage__');
    }

    // Set the search by image button url
    searchImageButton.href = '/searchbyimage?image_url=' + imageURL;

    // Set additional options
    if (options['open-search-by-in-new-tab']) {
        searchImageButton.setAttribute('target', '_blank');
    }

    // Place the more sizes button
    link.parentElement.insertBefore(searchImageButton, link);
    link.parentElement.insertBefore(link, searchImageButton);

}

You might've mixed up a few of the design things (as far as I can tell, the set search by image text code is the wrong way round for FEB18 and JUL19)

bijij commented 4 years ago

I'll see if I can get that fixed now then yeah i think i stuffed up when i moved from the two state version to N state.

I'll see if i can fix the left padding when you have the globe disabled too. didn't notice the text wasn't centred correctly.

bijij commented 4 years ago

Obviously let me know if my changes there doesn't actually fix it. Can't test myself due to my site version being different now.

needforsuv commented 4 years ago

Commit de1a0ae fixed the search image text being applied to the visit button, but the search by image is still getting its label from the 'find out more' box and I can't set it via options (no biggie though, I can custom css an interrim solution)

image of issue

needforsuv commented 4 years ago

as for the padding, it's because the globe on/off padding is different with the icon, I just custom css'd my way around it, amongst other things it's nothing in the grand scheme of things (it's because the visit thingy that the view image button clones itself from has asymmetrical padding already)

bijij commented 4 years ago

@needforsuv is there an error to console related to the extension? or is it setting some other element somewhere else to the desired text.

oh wait i see the issue i think. container.querySelector('span');

should be searchImageButton.querySelector('span');

Pushed a new release 3.2.2 which should fix that too hopefully.