ssborbis / ContextSearch-web-ext

Search engine manager for modern browsers
354 stars 37 forks source link

help request : right clicking an image to open it with https://images.weserv.nl/?url new url #654

Closed rezad1393 closed 1 year ago

rezad1393 commented 1 year ago

I use this addon https://github.com/SanderRonde/CustomRightClickMenu and added this (copyied it as I am not a pro)

var target = crmAPI.contextData.target; // Get the clicked element
if (!target) { // Make sure it exists, if it doesn't, show an alert
    alert('No target selected');
    return;
}

// Find the closest link to what was clicked
var currentElement = target;
while (currentElement && !currentElement.href) {
    currentElement = currentElement.parentNode; 
}

// If we selected a link, open the new URL with the
// link target pasted in
if (currentElement && currentElement.href) {
        // Change the URL below to point to your preferred URL
    window.open(`https://images.weserv.nl/?url=${currentElement.href}`, '_blank');
} else {
        // If nothing was selected, show an alert
    alert('Target is not a link!');
}

to open images in the new added url with this format : https://images.weserv.nl/?url

but that addon is kinda abandoned and has issues with hijacking userscripts files that end in '.js' name.

is there a way to do this with script option in this addon?

ssborbis commented 1 year ago

Are you looking to simply use that engine with this addon, or are you wanting to link your right-click to exclusively launch that one engine in particular?

rezad1393 commented 1 year ago

i dont get the difference. i want to pass the image ( or image target ) url to the https://images.weserv.nl/?$url

ssborbis commented 1 year ago

You can try this. Extract the .zip and use the Import button and see if that's what you're wanting.

images.webserv.nl.json.zip

image

rezad1393 commented 1 year ago

thank you. it works with images.

but not image target ( images that are the target of image).

so for example if I have an image that is shown and it is a thumbnail but clicking that image open the big picture (another picture), then using this method opens the thumbnail image in the url I need, but not the the target image.

so I am asking if the URL can be href of image property instead of src property. choosing link instead of image doesn't work.

can that be done?

ssborbis commented 1 year ago

I can't think of a current workaround, but I'm looking into adding something for the next release. i'll keep you updated

ssborbis commented 1 year ago

It seems a lot of sites ( search engines ) don't have a direct href from thumbnails to the full size images, so most workarounds would need to be site-specific. Is there a specific site you're wanting this to work with, or a general thumbnail -> full size solution?

rezad1393 commented 1 year ago

It seems a lot of sites ( search engines ) don't have a direct href from thumbnails to the full size images, so most workarounds would need to be site-specific. Is there a specific site you're wanting this to work with, or a general thumbnail -> full size solution?

I dont know if I got you right, but you mean that I send a thumbnail link to a website and that site convert it to full image?

what I meant was something else. disregard the tuhmbnail/fullpage thing,

say there is an image.

then I right click on it with this addon and select the search option you provided (thanks btw) it would use the displayed image url (which in html code is src of that image) and would then open https://images.weserv.nl/?url=SRC

but left clicking that same image can go to a new link. that link can be a html page or video or rar file or even an image.

how can I make it that right-clicking the image and selecting the search option again, would instead of src use href (destination of link) instead. https://images.weserv.nl/?url=href

btw, what is the %s parameters? I always used {searchterms} with your addon.

ssborbis commented 1 year ago

So, you're ONLY wanting to use the href=URL and not the image src=URL?

btw, what is the %s parameters? I always used {searchterms} with your addon.

Just a shorthand for {searchTerms}. There are some instances where one is preferred over the other. There is is also

lowsercase -> {searchterms} or %sl uppercase -> {SEARCHTERMS} or %su

and a few others

rezad1393 commented 1 year ago

that was sarcasm right? english is not my first language so I may not have got it.

I asked for that cause the other addon (customrightclickmenu) gets the target link (href) and uses that.

ssborbis commented 1 year ago

that was sarcasm right?

No. We must be having a miscommunication.

Given this image + link :

<a href="http://example.com/link.html">
     <img src="thumbnail.jpg" />
</a>

,,, you want {searchTerms} to be http://example.com/link.html and NOT thumbnail.jpg, correct?

rezad1393 commented 1 year ago

exactly.

<a href="http://example.com/link.html">
     <img src="http://anothersite.com/thumbnail.jpg" />
</a>

right now it uses http://anothersite.com/thumbnail.jpg when using on an image.

you have something for: Links can be searched as the text displayed or the url they refer to. Hold CTRL to toggle from the default setting

maybe images with links can have something like that.

ssborbis commented 1 year ago

I'll look into setting something up.

rezad1393 commented 1 year ago

I'll look into setting something up.

I just want to say thank you. you have answered my issues in this post and others and I appreciate that.

for comparison I reported an issue (an obvious issue that was actually acknowledged) but the dev just gave a one line answer as:

Yes. If you want a better converter, use a different program. I don't plan to improve this conversion.

you can see that bug here: https://gitlab.com/mbunkus/mkvtoolnix/-/issues/3566

I cant call that dev rude and he is not my slave to do my bidding but the answer was really ..... weird and left a bad taste in my mouse for reporting a very good bug and trying to do my part to improve an application I use.

ssborbis commented 1 year ago

I think I speak for most devs when I say we appreciate the bug reports and feature suggestions. This addon wouldn't be what it is without input from people willing to take the time to make reports.

ssborbis commented 1 year ago

If you're in a position to test, there's some updated code in the master branch that allows holding CTRL when opening the menus to use the link URL vs the image src.

rezad1393 commented 1 year ago

2023-08-15_10-40

If you're in a position to test,

I really am not right now :)

have to review a lot of pages and close them that I procrastinated on.

rezad1393 commented 1 year ago

I installed the new version.

when I press ctrl and right click I see the search parameter after "search for" is changed to https://blogger from https://images.weserv but after that clicking on search icon searches like before and I get https://images.weserv.nl/?url=https://images.weserv.nl/?url=blogger.googleusercontent again like before this update.

so to sum it up: it shows https://blogger.googleusercontent.xxxxxxxxxx url as parameter when I ctrl-right click but when I try to click (or ctrl-click by keeping ctrl pressed from right the right click) it again sees that parameter as https://images.weserv.nl/?url=blogger.googleusercontent.com

so the ctrl and ctrl-not-pressed give the same result. my search engine is this https://images.weserv.nl/?url=%s

p.s. the images.weserv.nl is an image proxy service so I cache my images through that, so google blog images get proxied through that (loaded through that) in my freshrss rss reaser (mostly for thumbnails) . but left clicking the image will open the non-thinbmail-original image on blogger.googleusercontent.com it original address.

so the two https://images.weserv.nl/?url=https://images.weserv.nl/?url=blogger.googleusercontent.com/images-thumbnail.jpg is because the addon send the current image url to the engine as parameter which is (https://images.weserv.nl/?url=blogger.googleusercontent.com/images-thumbnail.jpg) but I want to send the destination image url (which is full size image) to the engine as parameter https://blogger.googleusercontent.com/img.full.jpg

hope it is clear.

ssborbis commented 1 year ago

Ok, you're using the context menu. I'm not sure I checked that for the correct url. I'll check that out and get back to you.

rezad1393 commented 1 year ago

Ok, you're using the context menu. I'm not sure I checked that for the correct url. I'll check that out and get back to you.

what other option there is ? the toolbar search option?

btw, did you get my issue correctly? english in not my native tongue so if it is unclear I try again here:

use case: the is an image that is a thumbnail. right cliking on image in firefox and selecting open image opens the small thumbnail image. (left)clicking on image opens the full image size.

for search parameters of right click menu of this addon: normal right click --- >> = thumbnail image url. ctrl-right-click on image -->> the url in menu changes to the full size image but the actual search is done on the thumbnail url

ssborbis commented 1 year ago

I think I know what is happening. I'm working on updating some code. I'll let you know when I have something for you to test.

On a related note, if you can get the full image URL from the thumbnail url consistently... I mean to say, if you can look at the thumbnail URL and modify it in a way to get the actual full image URL, you can use this addon to change the target URL for you so you don't need to click into the thumbnail to get the full image before performing a search. It may be helpful to give me an actual link to look at.

rezad1393 commented 1 year ago

I think I know what is happening. I'm working on updating some code. I'll let you know when I have something for you to test.

On a related note, if you can get the full image URL from the thumbnail url consistently... I mean to say, if you can look at the thumbnail URL and modify it in a way to get the actual full image URL, you can use this addon to change the target URL for you so you don't need to click into the thumbnail to get the full image before performing a search. It may be helpful to give me an actual link to look at.

thank you for your code. I just explained because of language barrier. nothing more.

also the google thumbnail to full image or others are not really algorithm that I can find.

when you add this feature it makes this process way easier.

thank you again.

ssborbis commented 1 year ago

Are you on Firefox? I can get you a beta to try.

rezad1393 commented 1 year ago

are you on chrome(lbrave/other-chrome-children?) how would I test that firefox thingy that you yourself cant?

if it is uploaded to firefox addon store as a beta that I can only click and install, then sure I can try.

ssborbis commented 1 year ago

are you on chrome(lbrave/other-chrome-children?) how would I test that firefox thingy that you yourself cant?

I can and have tested it, but I'd like to get your assessment before putting new code into a release. I'll post a beta you can click to install in the next day or 2.

rezad1393 commented 1 year ago

thank you for your code. I just explained because of language barrier. nothing more.

again: if I com across as demanding or insulting I don't mean it. my question are more about curiosity than anything else.

ssborbis commented 1 year ago

No offense taken at all. I'm just trying to be as clear as I can be in my responses, since you are using translation software.

rezad1393 commented 1 year ago

since you are using translation software

what? I am NOT. I am real human. you can touch. for a price of course.

rezad1393 commented 1 year ago

Are you on Firefox? I can get you a beta to try.

this beta can just be dragged to firefox addon page and it will be installed? and when the stable release comes around, does the update is the same from addon page like normal addons?

ssborbis commented 1 year ago

this beta can just be dragged to firefox addon page and it will be installed?

That probably works. I think I just click to open, and Firefox asks to install. There are several methods that work.

and when the stable release comes around, does the update is the same from addon page like normal addons?

Yeah, the release should automatically replace the beta when it is available.

https://github.com/ssborbis/ContextSearch-web-ext/releases/download/v1.46.17b/contextsearch_web_ext-1.46.17b.xpi

rezad1393 commented 1 year ago

this beta can just be dragged to firefox addon page and it will be installed?

That probably works. I think I just click to open, and Firefox asks to install. There are several methods that work.

and when the stable release comes around, does the update is the same from addon page like normal addons?

Yeah, the release should automatically replace the beta when it is available.

https://github.com/ssborbis/ContextSearch-web-ext/releases/download/v1.46.17b/contextsearch_web_ext-1.46.17b.xpi

I tested and it works.

thanks.

BTW is there a way to make this default for a search engine (or if not selectively then all of them) so that I don't have to use ctrl?

other search engines I use are text selection and search so I don't think changing the default would hurt them.

I have seen this toggle : Links can be searched as the text displayed or the url they refer to. Hold CTRL to toggle from the default setting

but I think that is for text links. cause setting it to link doesnt work and I still need to hild ctrl.

maybe add one for images or if not possible merge them?

though is you add this setting, the best way would be to be per engine preferences so that user can use an engine by default got a image it shows and another one for image it points too.

rezad1393 commented 1 year ago

sorry if I ask for too much.

rezad1393 commented 1 year ago

hi another thing.

I recently am trying to see if I can move from firefox to brave. many extensions work there but I can use this beta there. can you upload a chrome-extension beta too?

btw, search engine icons don't work on brave.

ssborbis commented 1 year ago

can you upload a chrome-extension beta too?

You don't need a signed package for chrome-based browsers. You simply download the source code, click "Load unpacked" from the Extensions menu, and browse to the source code folder.

btw, search engine icons don't work on brave.

I assume you mean from the Context Menu? Chrome-variants can't show icons in the context menu beyond the top tier menu

rezad1393 commented 1 year ago

thanks. I am kinda new to chrome (brave) and didn't know this stuff.

btw is it possible to switch the mode for search for one search engine only and remove the need to use ctrl for that engine?

ssborbis commented 1 year ago

btw is it possible to switch the mode for search for one search engine only and remove the need to use ctrl for that engine?

Not currently, but I'm looking into including other parameters like {searchTerms} but for things like {image}, or {link}. I don't have it worked out yet, but I'll keep you updated.

rezad1393 commented 1 year ago

thank you.

I loaded the addon but it seems that I need to keep the directory of the addon on my disk too. if I remove the directory then the update dont work.

also it is installed as another addon and not as an update.

ssborbis commented 1 year ago

I loaded the addon but it seems that I need to keep the directory of the addon on my disk too. if I remove the directory then the update dont work.

also it is installed as another addon and not as an update.

Both are true. You can disable the production version until a new release is out, then remove the temporary extension ( or disable ), and enable the production version again.

ssborbis commented 1 year ago

New version going up 1.46.17

ssborbis commented 1 year ago

new: params {audio}, {video}, {page}, {frame}, {link}, {image}, {selection} can be used in search engine templates

Needs testing. Changes pushed to the master branch

rezad1393 commented 1 year ago

thank you for your efforts. and of course last but not least thanks to me for reporting them :)))

btw I couldn't stomach chrome-based and moved back to the woke-firefox for now.

so I cant really test the folder load method like I could in brave.

but if you give a beta I will happiliy test it.

2023-08-15_10-40

If you're in a position to test,

I really am not right now :)

have to review a lot of pages and close them that I procrastinated on.

Screenshot_20231002_170420

as you can see I have gotten better.

rezad1393 commented 1 year ago

new update of addon on firefox. tested with {link} and that is what I needed and removes the ctrl key requirement.

btw if I use that search on a picture that has no destination link the search would be empty.

can I combine search parameter ? for example {link} first and if no link available {image}

ssborbis commented 1 year ago

btw if I use that search on a picture that has no destination link the search would be empty. can I combine search parameter ? for example {link} first and if no link available {image}

Not currently. Maybe I can add something. I'll keep you updated.