Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #=====================================================================================================
- # Author: Dan(v)
- # Date: 14/03/2022
- # Purpose: Read a clipboard containing a Tumblr (or Tumbex) URL
- # From that URL, determine whether that Tumblr account
- # has an accessible 'Archive' page or whether
- # (like the majority of Tumblr pages these days) that account
- # is blocked, at least to non-Tumblr users.
- #=====================================================================================================
- # For matching to Tumbex URLs
- $RegExTumbexURL = '^(http|https)s?:\/\/www.tumbex.com\/(?<PageName>.*.tumblr)\/.*$'
- # For matching to Tumbex URLs
- $RegExTumblrURL = '^https:\/\/(?<PageName>.*.tumblr).com.*$'
- # For matching with Tumblr page base URL, i.e. minus the 'archive' element
- $RegExTumblrBasePageURL = '^https:\/\/(?<PageName>.*.tumblr).com\/$'
- # You can define your browser preference here, either firefox or chrome
- $BrowserPreference = 'firefox' # or 'chrome'
- Clear-Host
- # Read a Tumbex URL from clipboard
- $UrlFromClipboard = Get-Clipboard
- Write-Output "Running script ... "
- # Seek a match to tumblr URL or a tumbex URL, can work with either.
- if (($UrlFromClipboard -match $RegExTumbexURL) -or ($UrlFromClipboard -match $RegExTumblrURL))
- {
- # Retrieve the matched value of the named capture group 'PageName' from the regular expression.
- $PageName = $Matches['PageName']
- Write-Output "Check page name: $PageName"
- # I like working with the Tumblr 'archive' page, so that's what I'm constructing and will visit
- # programmatically.
- $TumblrArchiveUrl = "https://$($PageName).com/archive"
- # Check if the Tumblr archive page results in an accessible page or whether one of the countless
- # Tumblr blogs 'blocked' by safe mode or some other crap.
- try
- {
- $WebResponse = Invoke-WebRequest -Uri $TumblrArchiveUrl
- }
- catch
- {
- Write-Warning "URL inaccessible, possibly in wrong format, missing characters perhaps?"
- }
- # Check the 'links href' property of the web response object. We are expecting one of the link's 'href'
- # properties will match that actual tumblr base page URL (minus '/archive')
- $Links = $WebResponse.Links.href
- # Check count of links, should be just 1 and should match the Tumblr base url for this page.
- if (($Links.Count -eq 1) -and ($Links -match $RegExTumblrBasePageURL))
- {
- Write-Output "We got an accessible page! Opening page in $($BrowserPreference) ...."
- # Open URL in users browser of choice, defined via variable near top of script
- # Piping to 'Out-Null' just to suppress a line of process information.
- [system.Diagnostics.Process]::Start($BrowserPreference,$TumblrArchiveUrl) | Out-Null
- }
- else
- {
- Write-Output "Page inaccessible, sorry"
- }
- }
- else
- {
- Write-Output "Does not appear to be an expected Tumbex URL...."
- }
- Write-Output "Script ended"
- #=====================================================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement