-
Notifications
You must be signed in to change notification settings - Fork 164
/
Get-Mattifestation.ps1
56 lines (46 loc) · 1.56 KB
/
Get-Mattifestation.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
function Get-Mattifestation {
<#
.SYNOPSIS
Function to calculate a user's mattifestations, the international
standard unit of internet-famousness.
TODO: -ATD flag to calculate the mattifestations of all ATD users.
Function: Get-Mattifestations
Author: @enigma0x3, @harmj0y
License: BSD 3-Clause
Required Dependencies: None
Optional Dependencies: None
.EXAMPLE
Get-Mattifestations -Handle enigma0x3
.EXAMPLE
"enigma0x3","harmj0y","sixdub" | Get-Mattifestation | Sort-Object Mattifestations -Descending | ft -AutoSize
.LINK
https://twitter.com/lee_holmes/status/289810790821789696
#>
[CmdletBinding()]
Param(
[Parameter(Position=0,Mandatory=$True,ValueFromPipeline=$True)]
[string]$Handle
)
begin {
try {
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$WC = New-Object Net.WebClient
if(($WC.DownloadString("https://twitter.com/mattifestation") -match '([,\d]+).*Followers')) {
[int]$Mattifestation = $Matches[1]
}
}
catch {
throw "Error contacting twitter.com"
}
}
process {
if(($WC.DownloadString("https://twitter.com/$Handle") -match '([,\d]+).*Followers')) {
[int]$User = $Matches[1]
}
$Properties = @{
Handle = $Handle
Mattifestations = [double]("{0:N3}" -f ($User / $Mattifestation))
}
New-Object PSObject -Property $Properties
}
}