Last active
January 19, 2017 02:33
-
-
Save Bluscream/c7ca591e51051c547fb6273997975f2f to your computer and use it in GitHub Desktop.
Epic pr0gramm NSFW Desktop Changer by Bluenight
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Epic pr0gramm NSFW Desktop Changer by Bluenight | |
| ######### Config hier ############### | |
| # bei tag kann noch ein Tag definiert werden... minvotes ist die mindest Anzahl von Upvotes die ein Bild haben muss | |
| $tag = "earthporn" | |
| # Kommaseparierte Liste an blacklisted Tags | |
| $blacklistTags = "kadse, repost" | |
| $minvotes = 200 | |
| $flags = "1" # 1 = sfw | 2 = nsfw | |
| $style = 2 #0 = unverändert | 2 = gestreckt | |
| ######### Config ende ############# | |
| Function Set-WallPaper($Value) | |
| { | |
| Set-ItemProperty -path 'HKCU:\Control Panel\Desktop\' -name wallpaper -value $value | |
| Set-ItemProperty -path "HKCU:Control Panel\Desktop" -name WallpaperStyle -value $style | |
| rundll32.exe user32.dll, UpdatePerUserSystemParameters | |
| } | |
| # NSFW Beliebt herunterladen | |
| $bilder = Invoke-RestMethod "http://pr0gramm.com/api/items/get?flags=$flags&promoted=1&tags=$tag" | |
| # Zufaellig ein Bild ausw�hlen bis es auf die Kriterien passt .. minvotes und typ jpg | |
| $upvotes=0 | |
| $filetype="" | |
| $valid = $true | |
| while(($upvotes -lt $minvotes) -or ($filetype -ne "jpg") -or (-not $valid)) { | |
| $valid = $true | |
| $randombild = $bilder.items | get-random | |
| $id = $randombild.id | |
| $upvotes = $randombild.up | |
| $filetype = $randombild.image.split(".")[1] | |
| # second check | |
| if(($upvotes -lt $minvotes) -or ($filetype -ne "jpg")) {continue} | |
| # zweiter api request nur wenn conditions matched | |
| $bildInfo = Invoke-RestMethod "http://pr0gramm.com/api/items/info?itemId=$id" | |
| $tags = $bildInfo.tags | |
| # tag iterate | |
| foreach($tag in $tags) | |
| { | |
| if($blacklistTags -contains $tag.tag) | |
| { | |
| $valid = $false | |
| continue | |
| } | |
| } | |
| } | |
| # URL ermitteln | |
| $imgurl = $randombild.image | |
| $imgurlfull = $randombild.fullsize | |
| if($imgurlfull){ | |
| $url = "full.pr0gramm.com/$imgurlfull" | |
| }else{ | |
| $url = "img.pr0gramm.com/$imgurl" | |
| } | |
| $url | |
| # Bild runterladen | |
| $filename = $env:temp+"\wall.jpg" | |
| invoke-webrequest $url -outfile $filename | |
| set-wallpaper $filename | |
| #### Jede Menge geklauter Code der irgendwie dafuer sorgt, dass Win10 den Desktop refresht | |
| $setwallpapersource = @" | |
| using System.Runtime.InteropServices; | |
| public class wallpaper | |
| { | |
| public const int SetDesktopWallpaper = 20; | |
| public const int UpdateIniFile = 0x01; | |
| public const int SendWinIniChange = 0x02; | |
| [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)] | |
| private static extern int SystemParametersInfo (int uAction, int uParam, string lpvParam, int fuWinIni); | |
| public static void SetWallpaper ( string path ) | |
| { | |
| SystemParametersInfo( SetDesktopWallpaper, 0, path, UpdateIniFile | SendWinIniChange ); | |
| } | |
| } | |
| "@ | |
| Add-Type -TypeDefinition $setwallpapersource | |
| [wallpaper]::SetWallpaper(($filename)) | |
| Write-Output "Done" | |
| #### Und Ende.. jetzt schoen zurueck in den Keller fappieren gehn |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment