Shows just fullsize Image with hotkeys & without pop-ups on many image-hosting sites
< Σχολιασμός για τον κώδικα Handy Image
but I couldn't get document to raw text. what do you mean?
All I can think of is 'document.body.innerHTML' is what you are asking for
regex
yea, regex isn't a great idea since it works thousands times slower than usual matches, btw, you can just add sites for script to work on in your script manager in scripts options (in greasemonkey) and it would show biggest image on the page that way if no selector rule is specified for the site.
That's it. Thank you!
I'v seen that. It would work almost everytime but I like to have regex as well :D
HJI is running on a custom website, showing biggest image
Am I missing something because this isn't working?
case "example.com":
i = document.body.innerHTML.match(/src="(http.+?\/files\/.+?\.jpg)/)[1];
break;
mmm, you should tell script on which pages you want it to work via @match
, not after it is already running on a website, cuz script disabled javascript on pages it run, and just wastes processing time starting to run where it shouldn't.
Am I missing something
yeap, you should have said that you wanted an url address ;p that's window.location.href
you can use browser console (ctrl+shift+k in firefox) to see what commands do what and their output for faster and more comfortable scripting btw.
If you mean I should replace 'i' with 'window.location.href' in that way I won't have any advantage of your script. like keeping the original url in the address bar. :/
If you mean I should replace 'i'
No, I don't mean that.
Then is it possible to run something similar to this in your script?
case "example.com":
i = document.body.innerHTML.match(/src="(http.+?\/files\/.+?\.jpg)/)[1];
break;
well, first - I have no idea what result you want to get with that code... if it works as you want it to - you can just copy-past it into my script without any problems, if it doesn't - still have no idea what you want it to do ;s
let's guess again - if you want to find img
with /files
in its src, this line in my script already does that:
i = q('img[src*="/files/"]');
I already did, I have it in your script and I can confirm with console.log that it returns an image url
case "example.com":
i = console.log(document.body.innerHTML.match(/src="(http.+?\/files\/.+?\.jpg)/)[1]);
break;
But wouldn't show the image (Didnt find image, waited ..ms to try again). Probably because 'i' is supposed to select and not to return text and was hoping for a way to do that.
let's guess again - if you want to findimg
with/files
in its src, this line in my script already does that:i = q('img[src*="/files/"]');
I know that and that was just an example of what I want using regex.
Probably because 'i' is supposed to select and not to return text and was hoping for a way to do that.
That's correct, i
is an img
object and it must have scr
attribute for image to be counted as found.
case "example.com":
img=document.createElement("img");
img.setAttribute('src', document.body.innerHTML.match(/src="(http.+?\/files\/.+?\.jpg)/)[1]);
i = img;
break;
Did the trick. Thank you :D
Match with regex
I love this script and find it really useful but would run into many issues when adding selectors for new sites. I was thinking of using simple match with regex which isn't the greatest method but should work for me. but I couldn't get document to raw text. Can you help me with that?