Created
July 15, 2020 00:17
-
-
Save NicoNekoru/98c96d601adccad986f6d8fe21396c27 to your computer and use it in GitHub Desktop.
This file contains 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
function Global:Find-TagQuestions | |
{ | |
param ( | |
[Parameter(Mandatory = $true, ValueFromPipeline = $true, Position = 0)] | |
[String]$Tag | |
) | |
# Checks raw source code of https://stackoverflow.com/questions/tagged/tag?tab=newest&pagesize=50 | |
$query = Invoke-WebRequest "https://stackoverflow.com/questions/tagged/$($tag)?tab=newest&pagesize=50" | | |
Select-Object -ExpandProperty RawContent | |
# Creates a variable with a regular expression | |
$regex = [regex]'id="question-summary-(.+)"' | |
# Finds matches of the regular expression and gets the question id (i.e. "/q/12345678") | |
$CL = (($regex.Matches($query).value -replace 'id="question-summary-') -replace '"') | |
# Creates a variable with the path to the history file for your browser | |
$Path = "path\to\browser\history" | |
# Checks the content of the history file for a regular expression that looks for Stack Overflow questions then gets the id of it | |
$History = Get-Content -Path $Path | | |
Select-String -AllMatches 'stackoverflow\.com\/(questions|q)\/[\d]+\/' | | |
ForEach-Object {(($_.Matches).Value -replace 'stackoverflow.com/(q|questions)/', '') -replace '/'} | |
# Checks each line in the initial regular expression and sees if it is not in the history and if not opens it with brave | |
ForEach ($item in $CL) | |
{ | |
$URI = "stackoverflow.com/q/$item" | |
if ($item -notin $History) | |
{ | |
& "Path\To\Browser\file.exe" $URI | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment