r/PowerShell • u/gitpull--rebase • Mar 08 '21
I made a script to update your desktop wallpaper to today's top upvoted reddit wallpaper
You can change the subreddit to another one, not all work but some like r/wallpaper r/wallpapers r/earthporn r/carporn etc. Mostly ones that allow only pictures to be posted
https://github.com/0Nikola0/SnuePape
Be sure to read the readme in case you the SSL error
47
u/Soxcks13 Mar 08 '21
Brb writing a script to upvote NSFW wallpapers
5
u/gitpull--rebase Mar 08 '21
too bad reddit doesn't show NSFW when you're not logged in :(. I actually had an idea about boob wallpapers lol
5
u/_cansir Mar 08 '21
( .)( .)
7
u/archiekane Mar 08 '21
Weirdly placed nipples...
2
5
Mar 08 '21
Not bad, do you have any control for filtering out NSFW content?
6
u/gitpull--rebase Mar 08 '21
Reddit doesn't show NSFW by default, unless you enable it or have it enabled on your account. Since this script is working without an account it's impossible to open nsfw post.
2
3
u/bepstar Mar 08 '21
I love the idea of this script! I get easily bored of wall papers so this would be awesome! I use brave Web browser and love the random HD pictures it throws up in the background every time you load a new tab and this would give similar functionality in Windows!
The only thing holding me back from using this script (please correct me if I'm wrong but I couldnt see this whilst reading the code) is the ability to be able to set the resolution of my screen (to filter out non compatible resolutions) For example I don't want to download a 1080p picture on my 1440 monitor as it will look blury. Or a wide screen image on a non widescreen monitor etc....
4
u/gitpull--rebase Mar 08 '21
First thing coming on my mind is when I was testing subreddits on which the script works, I found r/WQHD_Wallpapers. It's for better quality pictures. Now to get more in depth, yes it can be done.
The resolution is included either at the end of the link, or can be checked after you've opened the image. I think I can implement some kind of resolution options to choose from. This was more of a experiment if I would say. It's my 2nd - 3rd ever script in powershell. I can't give you ETA when I'll do the resolutions options. If you or anyone here has any ideas on how to better the script, feel free to fork it and make to most out of it. I will try to better it myself.
Thanks for the nice comment, I'm glad you reviewed it and you liked it
2
u/NotSmug Mar 08 '21
Yeah amazing idea, but I don't want some semi nude anime waifus to pop up one day and my wife starts questioning her life choices lol.
2
u/gitpull--rebase Mar 09 '21
you can try it yourself, open incognito so you're not logged into your account, and try to look for nsfw in reddit. you can't by default, and with that the script can't set nsfw wallpapers either
1
u/NotSmug Mar 09 '21
Did. Blows my mind. Gg. Still weird. Like I'm looking at a different computer I get confused with all the pictures.
11
u/jayson4twenty Mar 08 '21
Just an idea, Reddit URLs can be appended with .json and you'll get a JSON response. You can parse that rather than scrape the page.
6
Mar 08 '21
Too late - this project is now critical to the environment and parsing JSON would break everything. Request closed.
/s
1
u/mga1 Mar 08 '21
Regarding the TLS/SSL error, would that be fixable in your main script by stating which TLS versions your web request should use? I believe the following line is a good practice where it adds (bitwise-or) the TLS 1.2 support to whatever the default value is. If in the future Microsoft changes the default to be TLS 1.3 or TLS 1.9 or whatever, the bitwise-or will just add this 1.2 support, while keeping whatever higher version support it defaulted too. Too many times I've seen direct assignment of 1.2, which means the code will need to be maintained as TLS versions come and go, and industry best practices moves off the older ones (possibly weaker at that time). TLS 1.0 today is considered weak and recommended to be turned off for web servers.
2
u/gitpull--rebase Mar 08 '21
I'm fairly new to networking so I don't actually know how in depth most of this works so I can't really say. I'm also not familiar with TLS, first time I read about it was when I started getting the errors in my script. Can't say I understand most of what you said, but I'll save this comment and come back to it when I have more knowledge. If you have an idea on how to fix the problem, just fork the script. I would be more than happy to see it fixed. Also thanks for reviewing the script and for giving me useful feedback.
4
u/camelman912 Mar 08 '21
I use the following code in al my internal scripts that pull REST API data from some devices to bypass self-signed certificate errors:
###################################################################### # Allow the use of self signed certificates and set TLS ###################################################################### [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 #C# class to create callback $code = @" public class SSLHandler { public static System.Net.Security.RemoteCertificateValidationCallback GetSSLHandler() { return new System.Net.Security.RemoteCertificateValidationCallback((sender, certificate, chain, policyErrors => { return true; });) } } "@ #compile the class Add-Type -TypeDefinition $code #disable checks using new class #[System.Net.ServicePointManager]::ServerCertificateValidationCallback = { $True } [System.Net.ServicePointManager]::ServerCertificateValidationCallback = [SSLHandler]::GetSSLHandler()1
u/dasookwat Mar 08 '21
You should be ble to do a check, based on a webrequest, to check the response, and also try using the system proxy settings, and if that doesn't work, add the tls support. this is persistent only through the session, so it should not affect other operations. Extra bonus to safe the working settings in reg, so the next run, the check is not needed
2
2
1
u/2feetfrompeace Mar 08 '21
I love the idea of this script! Scripts like this show how fun PS can be.
50
u/[deleted] Mar 08 '21
hmm...the opportunities for chaos are ripe.