Two requests for Yandex searches
The first one should be easily possible, though it's not as easy as I thought.
The code below should work but didn't work
// ==UserScript==
// @name Force Yandex.ru to change to Yandex.com
// @namespace Yandex.rutoYandex.com
// @version 0.0.1
// @author hacker09
// @match https://yandex.ru/*
// @run-at document-start
// @description Force Yandex.ru to change to Yandex.com!
// ==/UserScript==
document.location.replace(location.href.replace('yandex.ru', 'yandex.com'));
Your second request should also be easy to do, but I wasn't able to see any boxes saying something like you said, so I can't help you. Can you print that box?
- Why do you even need to do that?
- Use adblock
@Konf
oh, N2 is true, I forgot about that haahha.
If your VPN isn't an browser based vpn, you can use another vpn on your browser like hola vpn or browsec, and have another vpn just for the yandex website, so that yandex won't redirect you to the url you don't want.
- Why do you even need to do that?
- Use adblock
- I already told you that.
- Not good enough. I can keep the nag message from appearing, and I do, but that doesn't solve the problem. Blocking the nag message just saves me the trouble of having to close it. But the result is that the first time I click the Similar Images button, it does nothing. I have to click it and then click it again before it will work.
Oh, also, I used Adblock to identify all the scripts, XHR's, CSS's, etc on the page and looked at them one by one. I couldn't find the actual nag message contained in any of them.
The first one should be easily possible, though it's not as easy as I thought.
The code below should work but didn't work
--------
Your second request should also be easy to do, but I wasn't able to see any boxes saying something like you said, so I can't help you. Can you print that box?
Yeah, it's tricky, isn't it? Yandex doesn't want to go where it doesn't want to go. It's very stubborn.
For the second thing, here is an example. I just went to yandex.com/images and had it search for 'this is a test'. Then I clicked on the first image result. Here's a URL to get you to the example page:
https://yandex.com/images/search?text=this%20is%20a%20test&rdrnd=976299&pos=0&img_url=https%3A%2F%2Fi.ytimg.com%2Fvi%2F7oaiFKPk6xc%2Fmaxresdefault.jpg&rpt=simage
Ok, so now we're there. You have a button in the section on the right. It says "Similar" and has a picture of a camera with a magnifying glass over it. Now, if I click that, I get a nag message. "Log in to Yandex to improve your search experience". Personally, I say my search experience would be improved if they'd shut the hell up. I can click the X in the corner to close it. And then when I click the Similar button, it will take me where I want to go, which is:
https://yandex.com/images/search?url=https%3A%2F%2Fi.ytimg.com%2Fvi%2F7oaiFKPk6xc%2Fmaxresdefault.jpg&rpt=imageview&text=this%20is%20a%20test
Now, notice that the button is a clickable link, and between clicks, the link changes. What I just posted was the link that we get after we've done the first click. But before we do that click, the URL is this:
https://yandex.com/images/search?pos=0&img_url=https%3A%2F%2Fi.ytimg.com%2Fvi%2F7oaiFKPk6xc%2Fmaxresdefault.jpg&rdrnd=635770&text=this%20is%20a%20test&rpt=simage#
It's the same as the URL of the page we're on, plus a # added at the end. I can right-click that link and ask it to open in a new tab. When I do, I get the same as the page I was already on. If, however, I click the link, get rid of the nag message, and THEN right-click to open in a new tab, I get the page I wanted.
You'll notice, also, that one click is enough for the page to remember. If I do the click and then go look at another image, and click the Similar button, I'll get to the Similar Images page, like I want to. If I don't, it will remember, and it will be waiting for me. If I go look at another image and right-click Similar to open it in a new tab, it'll just be a copy of the tab I'm already on. Same URL. And even more annoyingly, if I scroll through the suggested images in the frame on the right, click one of them, and then right click Similar for a new tab, I'll get the same search page, but it will have reverted back to the first image in the group.
So the trick is to make Yandex think we've done that first click. But how?
I think the best you can do is to contact the website support
Do you mean only that button, or maybe pop-up shows up somewhat else?
@Konf
oh, N2 is true, I forgot about that haahha.
If your VPN isn't an browser based vpn, you can use another vpn on your browser like hola vpn or browsec, and have another vpn just for the yandex website, so that yandex won't redirect you to the url you don't want.
But it is. It's browser-based. I use CyberGhost, because it's free and you can just set it and forget it. Pick a network and connect to it, and the extension will remember the network, connect to the network immediately when you launch the browser, stay connected all through the session, never let a webpage slip by without going through the network. You turn it on, it stays on. There are some other free extensions that I use on rare occasions, but you have to keep your eye on them to make sure they stay connected. If you look away, they'll disconnect and you won't know it. Same with system-wide VPN programs. They'll disconnect, and you won't realize it. I'm sticking with CyberGhost.
I think the best you can do is to contact the website support
Do you mean only that button, or maybe pop-up shows up somewhat else?
That's the one. I'm on Yandex.com, though, instead of .ru. And didn't the message come up for you?
Try this:
// ==UserScript==
// @name Yandex: single pop-up remover
// @description The script removes login pop-up that appears after click on a similar pictures button
// @version 1.0.0
// @include /^https:\/\/yandex\.(ru|com)\/images(|.*)$/
// @author Konf
// @namespace https://greasyfork.org/users/424058
// @compatible Chrome
// @compatible Opera
// @compatible Firefox
// @icon https://www.google.com/s2/favicons?domain=yandex.com&sz=32
// @require https://cdnjs.cloudflare.com/ajax/libs/arrive/2.4.1/arrive.min.js
// @run-at document-start
// @grant none
// @noframes
// ==/UserScript==
/* jshint esversion: 6 */
(function() {
'use strict';
let simulatedEv = false;
document.arrive('a.MMViewerButtons-SearchByImage', { existing: true }, (aNode) => {
aNode.addEventListener('click', listener);
});
function listener(ev) {
if (simulatedEv) {
simulatedEv = false;
return;
}
simulatedEv = true;
ev.target.click();
}
})();
@fsmlives
hahaha you are funny! Yeah I got that annoying box! So I can help you know.
How? it's very simple! Just make a script that does the first click for you! hahahaha, simple right?
Do you want me to make it or not?...
Even though your VPN It's browser-based, you can still go to your browser settings and disable the VPN extension for the yandex website only...
@fsmlives
hahaha you are funny! Yeah I got that annoying box! So I can help you know.
How? it's very simple! Just make a script that does the first click for you! hahahaha, simple right?
Do you want me to make it or not?...
Even though your VPN It's browser-based, you can still go to your browser settings and disable the VPN extension for the yandex website only...
Sure, let's see what you can do. Let me also try the script Konf just posted and see what happens.
Oh! Looks like he got it! But it doesn't hurt to have more than one script, you know? Sometimes one will break and you'll need the other.
Try this:
// ==UserScript== // @name Yandex: single pop-up remover // @description The script removes login pop-up that appears after click on a similar pictures button // @version 1.0.0 // @include /^https:\/\/yandex\.(ru|com)\/images(|.*)$/ // @author Konf // @namespace https://greasyfork.org/users/424058 // @compatible Chrome // @compatible Opera // @compatible Firefox // @icon https://www.google.com/s2/favicons?domain=yandex.com&sz=32 // @require https://cdnjs.cloudflare.com/ajax/libs/arrive/2.4.1/arrive.min.js // @run-at document-start // @grant none // @noframes // ==/UserScript== /* jshint esversion: 6 */ (function() { 'use strict'; let simulatedEv = false; document.arrive('a.MMViewerButtons-SearchByImage', { existing: true }, (aNode) => { aNode.addEventListener('click', listener); }); function listener(ev) { if (simulatedEv) { simulatedEv = false; return; } simulatedEv = true; ev.target.click(); } })();
There it is! You did it! You should totally publish it in the main repository!
Wait! Wait! The script isn't quite right yet! The right-click! If I right-click Similar to open the results in a new tab, I just get a duplicate tab. It doesn't go the the Similar Images page. Can we make it do that?
@fsmlives
hahaha you are funny! Yeah I got that annoying box! So I can help you know.
How? it's very simple! Just make a script that does the first click for you! hahahaha, simple right?
Do you want me to make it or not?...
Even though your VPN It's browser-based, you can still go to your browser settings and disable the VPN extension for the yandex website only...
I spoke too soon. Looks like we haven't quite got it licked yet. Let's give your script a try.
// ==UserScript==
// @name Yandex: single pop-up remover
// @description The script removes login pop-up that appears after click on a similar pictures button
// @version 1.0.1
// @include /^https:\/\/yandex\.(ru|com)\/images(|.*)$/
// @author Konf (modified by hacker09)
// @namespace https://greasyfork.org/users/424058
// @compatible Chrome
// @compatible Opera
// @compatible Firefox
// @icon https://www.google.com/s2/favicons?domain=yandex.com&sz=32
// @require https://cdnjs.cloudflare.com/ajax/libs/arrive/2.4.1/arrive.min.js
// @run-at document-start
// @grant none
// @noframes
// ==/UserScript==
/* jshint esversion: 6 */
(function() {
'use strict';
let simulatedEv = false;
document.arrive('a.MMViewerButtons-SearchByImage', { existing: true }, (aNode) => {
aNode.addEventListener('click', listener);
aNode.addEventListener("contextmenu", listener);
});
function listener(ev) {
if (simulatedEv) {
simulatedEv = false;
return;
}
simulatedEv = true;
ev.target.click();
}
})();
I've just fixed the right click "bug" in the code above.
I'm not in the mood of making another script for something that already works, if this script ever stops working just comment anything here again.
Ok, right click now works. Unfortunately, we have two problems:
1. After the first click, every subsequent right-click triggers a click event, so instead of getting the option to open the link in the new tab, it just goes there immediately.
2. With the first click, we still get a nag message.
I've been studying the element, and I know this much. The link code, pre-click, looks like this:
<a class="MMButton MMButton_type_link MMViewerButtons-SearchByImage MMViewerButtons-SearchByImage_view_two-lines" href="#" rel="noopener" target="_self">
And post-click, it becomes this:
<a class="MMButton MMButton_type_link MMViewerButtons-SearchByImage MMViewerButtons-SearchByImage_view_two-lines" href="/images/search?url=THE URL OF THE IMAGE GOES HERE, ENCODED&rpt=imageview&text=image%20search" rel="noopener" target="_self">
Now, I think that the operations pertaining to the Similar button are controlled by the following script:
https://yandex-images.naydex.net/9OGcx6435/b09b5eSuER6Q/Ng_XfsBKZXDRF6FSxyW0Fm1JvgtWXAUcnqwj1CfEgDZZMgvANbxPyFMQSVlS7fgvTFp6fzThFs_nq3-W-7D-ovBZMZ1zqacSUiWjh7fVBRLN-GrLxh9WfE3s4_eXdAb0_tCbsHWOf1uhIovZQgqajm9NmJ121SfPtZg9dD3gnfJiKZLcM3mFoANGs-clJyfz3N_7yUQtlIvPrUEn5NXHt26iK8P0fq-ogCG6mdGaeZ1v_VvdBDa3POVoPdTPA0-wQ2pC7nE6RyKR16GnBkeX4q7eGCnmfJeqHr_zdPQUxhf88HnAd32OS5FwS-lyaivtLV6ovzcUBc2lyQ01rQCOkeDYE-7w6eaDwHUhtbWXxRHeLfuIBEwHmy3cM0Q1hiRELpHr45ffnqricSvZIuhq7W0N2O_kl4aOR-teNg_Db-GDeiFfMSvGo9AEocY2Z_ewbXx7q6dOR9p_zuLnlvQ2tLyiaIHFL_6qQFLoCrKZGg4vTHhuRNe1DUX6_6c9c21RcDoBvkNrdWCRdeM3Rtdncxz-ynn2DGXq_h5y5zTWNBQ-gMqBNX5dmRIj6YgjiqmMHv5JTcc0pIwVqFxEDHMfQfOLMP4yG2YD4GQh5pVm16OvLumaFPw162-PwzQ2JJW0ztIbI_UPbBjC0guZkwmp_h1uqx929Gbsl0pMBa8j_eJDKeDcMQsVIqFkQnaXFuXBrX6b28T-tRgd3iL3F0ZVhq0DKyOWDe36QpBraLKLKnxt7xkupZbFPbfKrdW_0y-CgWvRz8BIRtIz17A2VrfWU-_uy_lVv4f7DO8i9xQ2VoY_kkiQJfx-CeOgWotjKNm-fo0arxbGJz7nau01bHF98fCIcx_ReZYhowegNyfV1-BOPdp5Ju-GGqzuQIXGVmR1LtJIMKXd_toxMMn4ktjIrC6_ys9XRzTMxruvVU5AzMFQOgC80cl2QbI1s1VV5JehPC5qSbW-VRqs7iP3Q
That's a long freaking URL! I believe, also, that the relevant lines are contained here:{return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),v=a()(h),g=Object(d.a)(l.b),b=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return m(t,e),t.prototype.render=function(){var e=this.props,t=e.onLog,n=e.onClickCounter,r=e.onClickLogNode,i=e.view,a=e.isSimilarUnauthPopupEnabled,s=e.onClick,d=e.experiments,h=this.getUrl();if(!h)return null;var m=i===p.b.compact||i===p.b.twoLines;return o.createElement(g,{className:Object(f.a)("SearchByImage",{view:i,similarButtonIcon:d&&d.similarButtonIcon}),logNode:a?void 0:{name:"cbir1",attrs:r&&r.attrs,events:{onClick:Object(c.logClick)(n)}},text:m?v("Похожие",{context:"Кнопка в проÑмотрщике картинки https://nda.ya.ru/3UYbqn"}):v("Другие размеры и похожие",{context:"Кнопка в проÑмоторщике картинки https://nda.ya.ru/3UYbqn"}),url:a?"#":h,target:this.getTarget(),icon:o.createElement(u.a,{type:"similar-search"}),type:l.a.link,onLog:a?void 0:t,onClick:s})},t.prototype.getUrl=function(){var e,t,n,r,o,i,a=this.props,c=a.image,u=a.imagesCbirSearchUrl,l=a.query,d=a.experiments,p=c.extraOrigin||(null===(t=null===(e=c.preview)||void 0===e?void 0:e[0])||void 0===t?void 0:t.origin)||(null===(r=null===(n=c.dups)||void 0===n?void 0:n[0])||void 0===r?void 0:r.origin)||(null===(o=c.preview)||void 0===o?void 0:o[0])||(null===(i=c.dups)||void 0===i?void 0:i[0]),f=(null===p||void 0===p?void 0:p.url)||c.imgHref;if(f){var h={url:f,rpt:"imageview"};return(null===d||void 0===d?void 0:d.searchByImageLinkWithoutText)||(h.text=l),Object(s.appendQueryString)(u,h)}},t.prototype.getTarget=function(){return this.props.openServiceOnNewTab?"_blank":"_self"},t}
If I right-click Similar to open the results in a new tab
Can't reproduce that.
Try this:
// ==UserScript==
// @name Yandex: single pop-up remover
// @description The script removes login pop-up that appears after click on a similar pictures button
// @version 1.0.1
// @include /^https:\/\/yandex\.(ru|com)\/images(|.*)$/
// @author Konf
// @namespace https://greasyfork.org/users/424058
// @compatible Chrome
// @compatible Opera
// @compatible Firefox
// @icon https://www.google.com/s2/favicons?domain=yandex.com&sz=32
// @require https://cdnjs.cloudflare.com/ajax/libs/arrive/2.4.1/arrive.min.js
// @run-at document-start
// @grant none
// @noframes
// ==/UserScript==
/* jshint esversion: 6 */
(function() {
'use strict';
let simulatedEv = false;
document.arrive('a.MMViewerButtons-SearchByImage', { existing: true }, (aNode) => {
aNode.addEventListener('click', function(ev) {
// make sure a LMB was pressed
if (ev.button !== 0 && ev.which !== 1) return;
if (simulatedEv) {
simulatedEv = false;
return;
}
simulatedEv = true;
ev.target.click();
});
});
})();
I've just fixed the right click "bug" in the code above
How was that supposed to be a fix?
@Konf
Isn't a fix, it's just more like what he wanted
Unfortunately, Konf's second version is just about the same as the first. Thank you for not giving up, though.
Is there anything helpful in that script from Yandex? Anything we can use? Has to be. The code for assigning URLs is there. I can't completely make sense of it, though.
I'm a novice. I really am. I can think of possible solutions, but I have no idea how to code them. But think of this. Could we do it in such a way that if the Similar button
a class="MMButton MMButton_type_link MMViewerButtons-SearchByImage MMViewerButtons-SearchByImage_view_two-lines"
has the property
href="#"
then a single click event is initiated? And could there be a second component where the nag message
div class="Popup2 Popup2_visible Modal Modal_visible Modal_hasAnimation Modal_theme_normal MMUnauthPopup __web-inspector-hide-shortcut__"
was suppressed? Would that take care of it? I don't know. I never learned to write Javascript. I learned some Java once long ago, some Visual Basic even further back, and some simple HTML here and there. But I'm clueless when it comes to Javascript.
Unfortunately, Konf's second version is just about the same as the first
Oh, I missunderstood... Wait a little
// ==UserScript==
// @name Yandex images: fsmlives helper
// @description The script removes login pop-up that appears after click on a similar pictures button and makes the button be actual link
// @version 2.0.0
// @include /^https:\/\/yandex\.(ru|com)\/images(|.*)$/
// @author Konf
// @namespace https://greasyfork.org/users/424058
// @compatible Chrome
// @compatible Opera
// @compatible Firefox
// @icon https://www.google.com/s2/favicons?domain=yandex.com&sz=32
// @require https://cdnjs.cloudflare.com/ajax/libs/arrive/2.4.1/arrive.min.js
// @run-at document-start
// @grant none
// @noframes
// ==/UserScript==
/* jshint esversion: 6 */
(function() {
'use strict';
document.arrive('a.MMViewerButtons-OpenImage', { existing: true }, (aNode) => {
const similarBtnNode = document.querySelector('a.MMViewerButtons-SearchByImage');
if (!similarBtnNode || !aNode.href) return;
const uri = encodeURI(aNode.href);
similarBtnNode.href = `https://yandex.com/images/search?rpt=imageview&url=${uri}`;
});
let simulatedEv = false;
document.arrive('a.MMViewerButtons-SearchByImage', { existing: true }, (aNode) => {
aNode.addEventListener('click', function(ev) {
if (simulatedEv) {
simulatedEv = false;
return;
}
simulatedEv = true;
ev.target.click();
});
});
})();
Nope. Afraid that last one broke the right-click option altogether. Even if I've clicked the normal way, when I try to open an image via right-click, the resulting page says, "Couldn't upload image. Try uploading a different one."
Parts of your scripts have worked. Parts of hacker09's script have worked. His version turned right-clicks into normal clicks, but they took me to the right page.
I don't know if you can figure this out, but when I make the first click on the Similar button, no userscripts changing anything, what actually happens under the surface? A nag message pops up, and the address of the Similar link changes. But it only takes the one click. (The trouble is remembering if this particular tab has gotten that click or not.) After that first click, the nag message never shows up again, and all further links go where they're supposed to. That has to mean that a variable changed under the surface, doesn't it? What was the variable? If I had to guess strictly based on Yandex's code, which I barely understand, I'd say there was a click counter. Whatever the variable is, can't we just change it when the page loads?
Again, just a suggestion: can we make a script that automatically clicks the Similar button if and only if href="#"?
The best thing to do is to give up on understanding and reading the website code, that's something very very hard and complex to do, that's why most devs just give up and make their own solution.
The href='#' may (or not) mean nothing... That's because advent listeners play an very important role and can change a lot of things in the background too...
As Konf said he couldn't reproduce that, so this may be why he couldn't make the code work, I could reproduce what you said, but I couldn't (too lazy) make it open on another tab.
What browser do you use?
Chrome.
The href='#' may (or not) mean nothing... That's because advent listeners play an very important role and can change a lot of things in the background too...
The href="#" is consistent, though. Before the first click, the href for the Similar button is always "#". We can set our watch by it. If we can get the userscript to detect whether href="#", we might be able to just put the fancy stuff inside an If statement, and that might solve all the problems. Can we write a script that goes something like If MMViewerButtons-SearchByImage href="#", then click event? Is that something we can do? I don't know enough about javascript, but I know some things about conditional statements. It seems like it should be possible.
Chrome
Me too, and the last script works for me. Maybe you will make a video with your problem? Address bar should be visible on it
Ok. Took a bit of time. I don't have a good video capture program, so instead I took enough screenshots to tell the story. First, a basic search page:
https://yandex.com/images/search?text=moody%20blues&rdrnd=78453
Second, clicking on the first result, just for ease:
https://yandex.com/images/search?text=moody%20blues&rdrnd=78453&pos=0&img_url=https%3A%2F%2Fmakeyourowntaste.files.wordpress.com%2F2015%2F02%2Fbd526d_c85f218049f2c5cbd619a95302068fd2.jpg&rpt=simage
Basic click, by the way, works in all forms. But when we right-click, we go someplace that's no help to anybody:
https://yandex.com/images/search?rpt=imageview&rpt=simage&url=https%3A%2F%2Fyandex.com%2Fimages%2Fsearch%3Fpos%3D0&img_url=https%253A%252F%252Fmakeyourowntaste.files.wordpress.com%252F2015%252F02%252Fbd526d_c85f218049f2c5cbd619a95302068fd2.jpg&rdrnd=515791&text=moody%2520blues&redircnt=1615582512.4#
The problem is the encoded URL. Instead of an encoded version of the image url, we have an encoded version of the Yandex page that gave this search result. Since a page isn't an image, it can't do anything with it.
Now, the correct url would be one of the following. They all get us to the same place, basically. The first result references some cached image in Yandex's database. For efficiency, perhaps? Now, if instead of looking at that URL we look at the actual link that Similar gives us, we see that it gives an encoded url, but for a different instance of the same image than what was referenced in the URL of the first result page above. Why? No good reason at all. We can change the encoded url to match what we got in the initial result page, though. Either use with the encoded URL of the actual image will take us, ultimately, to a page that converts the image URL into something pointlessly long, which we can ignore because it doesn't matter. In any case, all results lead us to the same page.
Referencing internal:
https://yandex.com/images/search?rpt=imageview&text=moody%20blues&rdrnd=153815&redircnt=1615582840.4&url=https%3A%2F%2Favatars.mds.yandex.net%2Fget-images-cbir%2F4566351%2FWUFle1l0C1VbmQGNgFIXXQ4214%2Forig&cbir_id=4566351%2FWUFle1l0C1VbmQGNgFIXXQ4214
Referencing actual image URL (what I would aim for):
https://yandex.com/images/search?url=https%3A%2F%2Fwww.notelyrics.com%2Fimages%2FT%2FThe%2520Moody%2520Blues%2FThe%2520Moody%2520Blues_2.jpg&rpt=imageview&text=moody%20blues
https://yandex.com/images/search?url=https%3A%2F%2Fmakeyourowntaste.files.wordpress.com%2F2015%2F02%2Fbd526d_c85f218049f2c5cbd619a95302068fd2.jpg&rpt=imageview&text=moody%20blues
// ==UserScript==
// @name Yandex: single pop-up remover
// @description The script removes login pop-up that appears after click on a similar pictures button
// @version 0.1
// @include /^https:\/\/yandex\.(ru|com)\/images(|.*)$/
// @author hacker09
// @namespace yandex pop-up remover
// @compatible Chrome
// @compatible Opera
// @compatible Firefox
// @icon https://www.google.com/s2/favicons?domain=yandex.com&sz=32
// @require https://cdnjs.cloudflare.com/ajax/libs/arrive/2.4.1/arrive.min.js
// @run-at document-start
// @grant none
// @noframes
// ==/UserScript==
/* jshint esversion: 6 */
(function() {
'use strict';
//The direct link could also be accessed using document.querySelector("a.MMViewerButtons-SearchByImage").__reactEventHandlers$jo9pgiwjop.onClick().[[Scopes]].[2].$.ajaxSettings.url
//But I don't know how to do this...
document.arrive('a.MMViewerButtons-SearchByImage', { existing: true }, (aNode) => {
aNode.addEventListener('click', function(ev) {
if(aNode.href === location.href + '#')
{
aNode.click();
}
});
aNode.addEventListener('contextmenu', function(ev) {
if(aNode.href === location.href + '#')
{
aNode.click();
window.open(aNode.href);
setTimeout(function(){
if(document.querySelector("div.Popup2.Popup2_visible.Modal.Modal_visible.Modal_hasAnimation.Modal_theme_normal.MMUnauthPopup") !== null)
{
console.log(2)
document.querySelector("div.Popup2.Popup2_visible.Modal.Modal_visible.Modal_hasAnimation.Modal_theme_normal.MMUnauthPopup").remove();
}
}, 500);
}
ev.preventDefault(); //Prevent the default action
ev.stopPropagation(); //Prevent the default action
});
});
})();
Now it opens the link even if the login pop up is shown, but usually the script is faster than the pop up so you can't even see the pop up on the first time, and as you said the link won't be # after the first click, so the login box will never appear again after the first click.
Now if you right click on the find similar box the script will open the correct link in a new tab
Another point about the Yandex image search: You click an image result, which we will call Example A, and you get a page with an encoded version of the url of the image you've chosen:
img_url=httpshttps%3A%2F%2F Example A
But when you have that result page up, the side bar on the right has results for more images that may be relative to the first. You can click one of the images in that sidebar, Example B, and it will fill up the little image window. But as for the URL changing, it does so in a weird way:
img_url=httpshttps%3A%2F%2F Example A &rlt_url=https%3A%2F%2F Example B &ogl_url=https%3A%2F%2F Example A
And see, that's where I run into trouble so often. That's the biggest reason for this script. If I'm going through images in that sidebar, and I try to open Similar in a new tab, and I haven't addressed the nag message, then the new tab reverts to the basic result page with Example A, as above:
img_url=httpshttps%3A%2F%2F Example A
So, point in all this is, if we wanted to use the referenced images from the search URL itself, and have them replace the URL for the Similar button, if that's the way we would attempt to tackle this, what we would want is for the script to first attempt to grab the address referenced by rlt_url=, and if that were not present, then to use img_url=. Would that be possible? Would that work?
Works for me. Can't reproduce. Disable your extensions, etc
Did my last script work for you?
Now it opens the link even if the login pop up is shown, but usually the script is faster than the pop up so you can't even see the pop up on the first time, and as you said the link won't be # after the first click, so the login box will never appear again after the first click.
Now if you right click on the find similar box the script will open the correct link in a new tab
I'm afraid that one hasn't got it either. When I right-click, it opens the image in a new tab, without even asking what I want. And it only opens the image in a new tab once. Just once. Any subsequent time, the right-click does nothing.
https://yandex.com/images/search?text=moody%20blues&rdrnd=78453&pos=0&imgurl=https%3A%2F%2Fmakeyourowntaste.files.wordpress.com%2F2015%2F02%2Fbd526dc85f218049f2c5cbd619a95302068fd2.jpg&rpt=simage
But what your script sends me to is https://yandex.com/images/search?rpt=imageview&rpt=simage&url=https%3A%2F%2Fyandex.com%2Fimages%2Fsearch%3Fpos%3D0&img_url=https%253A%252F%252Fmakeyourowntaste.files.wordpress.com%252F2015%252F02%252Fbd526d_c85f218049f2c5cbd619a95302068fd2.jpg&rdrnd=515791&text=moody%2520blues&redircnt=1615582512.4# .
It's easy to make the last script I did do something when right-clicked subsequent times.
I also couldn't see that message "error image not uploaded"...
My script correctly opened and uploaded the image on the first right click try...
// ==UserScript==
// @name Yandex: single pop-up remover
// @description The script removes login pop-up that appears after click on a similar pictures button
// @version 0.2
// @include /^https:\/\/yandex\.(ru|com)\/images(|.*)$/
// @author hacker09
// @namespace yandex pop-up remover
// @compatible Chrome
// @compatible Opera
// @compatible Firefox
// @icon https://www.google.com/s2/favicons?domain=yandex.com&sz=32
// @require https://cdnjs.cloudflare.com/ajax/libs/arrive/2.4.1/arrive.min.js
// @run-at document-start
// @grant none
// @noframes
// ==/UserScript==
/* jshint esversion: 6 */
(function() {
'use strict';
//The direct link could also be accessed using document.querySelector("a.MMViewerButtons-SearchByImage").__reactEventHandlers$jo9pgiwjop.onClick().[[Scopes]].[2].$.ajaxSettings.url
//But I don't know how to do this...
document.arrive('a.MMViewerButtons-SearchByImage', { existing: true }, (aNode) => {
aNode.addEventListener('click', function(ev) {
if(aNode.href === location.href + '#')
{
aNode.click();
}
});
aNode.addEventListener('contextmenu', function(ev) {
if(aNode.href === location.href + '#')
{
aNode.click();
setTimeout(function(){
if(document.querySelector("div.Popup2.Popup2_visible.Modal.Modal_visible.Modal_hasAnimation.Modal_theme_normal.MMUnauthPopup") !== null)
{
document.querySelector("div.Popup2.Popup2_visible.Modal.Modal_visible.Modal_hasAnimation.Modal_theme_normal.MMUnauthPopup").remove();
}
}, 1000);
}
window.open(aNode.href);
ev.preventDefault(); //Prevent the default action
ev.stopPropagation(); //Prevent the default action
});
});
})();
Now the script also does open the link in a new tab when right-clicked subsequent times.
// ==UserScript==
// @name Yandex: single pop-up remover
// @description The script removes login pop-up that appears after click on a similar pictures button
// @version 0.3
// @include /^https:\/\/yandex\.(ru|com)\/images(|.*)$/
// @author hacker09
// @namespace yandex pop-up remover
// @compatible Chrome
// @compatible Opera
// @compatible Firefox
// @icon https://www.google.com/s2/favicons?domain=yandex.com&sz=32
// @require https://cdnjs.cloudflare.com/ajax/libs/arrive/2.4.1/arrive.min.js
// @run-at document-start
// @grant none
// @noframes
// ==/UserScript==
/* jshint esversion: 6 */
(function() {
'use strict';
//The direct link could also be accessed using document.querySelector("a.MMViewerButtons-SearchByImage").__reactEventHandlers$jo9pgiwjop.onClick().[[Scopes]].[2].$.ajaxSettings.url
//But I don't know how to do this...
document.arrive('a.MMViewerButtons-SearchByImage', { existing: true }, (aNode) => {
aNode.addEventListener('click', function(ev) {
window.open('https://yandex.com/images/search?url='+ document.querySelector("img.MMImage-Origin").src +'&rpt=imageview', "_self");
});
aNode.addEventListener('contextmenu', function(ev) {
setTimeout(function(){
if(document.querySelector("div.Popup2.Popup2_visible.Modal.Modal_visible.Modal_hasAnimation.Modal_theme_normal.MMUnauthPopup") !== null)
{
document.querySelector("div.Popup2.Popup2_visible.Modal.Modal_visible.Modal_hasAnimation.Modal_theme_normal.MMUnauthPopup").remove();
}
}, 1000);
window.open('https://yandex.com/images/search?url='+ document.querySelector("img.MMImage-Origin").src +'&rpt=imageview');
ev.preventDefault(); //Prevent the default action
ev.stopPropagation(); //Prevent the default action
});
});
})();
You can try using the version above to see/check if the image is correctly uploaded to yandex and displayed along with similar images...
Fixed, I guess
// ==UserScript==
// @name Yandex images: fsmlives helper
// @description The script removes login pop-up that appears after click on a similar pictures button and makes the button be actual link
// @version 3.0.0
// @include /^https:\/\/yandex\.(ru|com)\/images(|.*)$/
// @author Konf
// @namespace https://greasyfork.org/users/424058
// @compatible Chrome
// @compatible Opera
// @compatible Firefox
// @icon https://www.google.com/s2/favicons?domain=yandex.com&sz=32
// @require https://cdnjs.cloudflare.com/ajax/libs/arrive/2.4.1/arrive.min.js
// @run-at document-start
// @grant none
// @noframes
// ==/UserScript==
/* jshint esversion: 6 */
(function() {
'use strict';
document.arrive('img.MMImage-Origin', { existing: true }, (aNode) => {
new MutationObserver(imgHandler).observe(aNode, { attributes: true });
});
function imgHandler(mutations, observer) {
const similarBtnNode = document.querySelector('a.MMViewerButtons-SearchByImage');
const imgNode = mutations[0].target;
const ev = document.createEvent('HTMLEvents');
ev.initEvent('contextmenu', true, false);
imgNode.dispatchEvent(ev);
observer.takeRecords();
if (!similarBtnNode || !imgNode.src || imgNode.src === (location.href + '#')) {
return;
}
const uri = encodeURI(imgNode.src);
similarBtnNode.href = `https://yandex.com/images/search?rpt=imageview&url=${uri}`;
}
let simulatedEv = false;
document.arrive('a.MMViewerButtons-SearchByImage', { existing: true }, (aNode) => {
aNode.addEventListener('click', function(ev) {
if (simulatedEv) {
simulatedEv = false;
return;
}
simulatedEv = true;
ev.target.click();
});
});
})();
Now even better...
// ==UserScript==
// @name Yandex images: fsmlives helper
// @description The script removes login pop-up that appears after click on a similar pictures button and makes the button be actual link
// @version 3.0.1
// @include /^https:\/\/yandex\.(ru|com)\/images(|.*)$/
// @author Konf
// @namespace https://greasyfork.org/users/424058
// @compatible Chrome
// @compatible Opera
// @compatible Firefox
// @icon https://www.google.com/s2/favicons?domain=yandex.com&sz=32
// @require https://cdnjs.cloudflare.com/ajax/libs/arrive/2.4.1/arrive.min.js
// @run-at document-start
// @grant none
// @noframes
// ==/UserScript==
/* jshint esversion: 6 */
(function() {
'use strict';
function fixSimilarBtn(imgNode) {
const similarBtnNode = document.querySelector('a.MMViewerButtons-SearchByImage');
if (!similarBtnNode || !imgNode.src || imgNode.src === (location.href + '#')) {
return;
}
const uri = encodeURI(imgNode.src);
similarBtnNode.href = `https://yandex.com/images/search?rpt=imageview&url=${uri}`;
}
document.arrive('img.MMImage-Origin', { existing: true }, (aNode) => {
fixSimilarBtn(aNode);
new MutationObserver(function(mutations, observer) {
const ev = document.createEvent('HTMLEvents');
ev.initEvent('contextmenu', true, false);
aNode.dispatchEvent(ev);
observer.takeRecords();
fixSimilarBtn(aNode);
}).observe(aNode, { attributes: true });
});
let simulatedEv = false;
document.arrive('a.MMViewerButtons-SearchByImage', { existing: true }, (aNode) => {
aNode.addEventListener('click', function(ev) {
if (simulatedEv) {
simulatedEv = false;
return;
}
simulatedEv = true;
ev.target.click();
});
});
})();
Ok, finally checking these new scripts.
Hacker09's script helps, sort of. The right-click action automatically opens the link in a new window, without even asking what I'd like to do. However, for my purposes, it's better than the default behavior. If I'm right-clicking, it's because I want to open a tab in a new window. Interestingly enough, now, if I do a regular click, the nag message still appears!
Now Konf's script. Yes, I think they've licked it. Right-click gives me the customary menu, and when I choose to open in a new tab, it gives me the correct image. Regular click works the way it should, too. Goes right to the Similar Images page with no nag message. Testing and re-testing, and so far, it seems to work perfectly! Well done!
Thank you both for taking time to work on my problem. I appreciate it.
If I'm right-clicking, it's because I want to open a tab in a new window
People have invented a middle mouse button for that. Or you can bind some another button with a script
If I'm right-clicking, it's because I want to open a tab in a new window
People have invented a middle mouse button for that. Or you can bind some another button with a script
Yeah, but a lot of the time, I'm working on an Android tablet, using the Kiwi browser with the Violentmonkey userscript extension. Purely touchscreen action.
Ok. So, first of all, Yandex doesn't want to let the end user choose whether they navigate Yandex.com or Yandex.ru. It wants to choose for them based on the location of their IP. This is a big deal, because Yandex.com is in English while Yandex.ru is in Russian. I use VPNs. Some of them make Yandex send me to Yandex.ru. I'm not going to change which VPNs I use, because there can be real speed differences. Now, in some cases, Yandex can be overriden. If you're doing a search via Yandex images, you can change the .ru to .com, and it will stick. I use a redirector plugin to change all Yandex Image searches from .ru to .com. But with ordinary searches, this does not work. Yandex keeps saying, "No, you don't want to go to Yandex.com. You want to go to Yandex.ru." And it insists until the browser gives up because of too many redirects. So I can't use my redirector for that. So, is there a way to fix this with a script? Can we force Yandex to go where we want it to, instead of where it wants us to?
Second request is for Yandex Image search. This is a nuisance. When I use Yandex image search, and I click the button for Similar Images, it will sometimes give me a popup that says, "You know, this could work better for you if you logged into a Yandex account." After I tell it I don't want to do that, then I can click the button and get to the similar images page. I don't want that intermediate step. I want to skip it. I want the Similar Images button to take me to similar images, every time, without exception. It's especially annoying because I'll right-click Similar Images to open it in a new window, and I'll do this for a couple of results, and if the original page was going to stay on the basic image search page and give me a nag message, then every one of those pages I just opened will still be on the basic image search page, and I'll have to click Similar Images and go through the nag message on every single one of them before I can get to the similar images page like I wanted to. Can we knock out the nag step?
Thanks.