Skip to content

Instantly share code, notes, and snippets.

@hare1039
Last active January 27, 2020 18:29
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hare1039/d29bfff8d88aa5e61e34a21ee1cc2acb to your computer and use it in GitHub Desktop.
Save hare1039/d29bfff8d88aa5e61e34a21ee1cc2acb to your computer and use it in GitHub Desktop.
This powershell script helps creaters on iwara accept or delete friend requests. Instructions: https://jet.hare1039.nctu.me/2020-01-25-Windows-Iwara-Script/
# Created by hare1039
$ErrorActionPreference = "Inquire"
$key = Read-Host -Prompt 'Enter Cookie Key'
$value = Read-Host -Prompt 'Enter Cookie Value'
Write-Host '[1] Accept all friend requests'
Write-Host '[2] Delete all friend requests'
$mode = Read-Host -Prompt 'Please enter 1 or 2'
if ($mode -eq "1") {
$IWARA_HTTP_METHOD="PUT"
} elseif ($mode -eq "2") {
$IWARA_HTTP_METHOD="DELETE"
$mode = Read-Host -Prompt 'Do you really want to delete all friend request?[Y/n]'
if ($mode -like '*n*') {
Write-Host 'Abort'
exit
}
} else {
exit
}
$cookie = New-Object System.Net.Cookie
$cookie.Name = "$key"
$cookie.Value = "$value"
$cookie.Domain= "ecchi.iwara.tv"
# inject cookie
$session = New-Object Microsoft.PowerShell.Commands.WebRequestSession
$session.Cookies.Add($cookie)
Write-Host "fetching friend list page"
$res = Invoke-WebRequest -Uri 'https://ecchi.iwara.tv/user/friends' -WebSession $session
# get last page number
$last = ($res.AllElements | Where {$_.TagName -eq 'li'} | Where {$_.Class -like '*pager-last*'})
if ($last)
{
$last = $last.innerHTML.Split('"')[1]
$last = $last.Split('=')[1]
}
else
{
$last = "0"
}
$last = [int]$last
$usermax = Read-Host -Prompt "What is the max page number in your friend pages? [auto detect: $last]"
if ($usermax -ne "")
{
$last = [int]$usermax
}
Write-Host "looping through all friend pages 0 -> $last"
Write-Host ""
Write-Host "Sometimes a request did not process successfully due to various reasons"
Write-Host "But this script will skip that request and continue with the others"
Write-Host "So no worries when some errors pop up"
Write-Host ""
$count = 0
$ErrorActionPreference = "Continue"
For ($i=$last; $i -ge 0; $i--)
{
#get request list
$res = Invoke-WebRequest -Uri "https://ecchi.iwara.tv/user/friends?page=$i" -WebSession $session
$res.AllElements |
Where {$_.TagName -eq 'button'} |
Where {$_.class -like '*accept-friend*'} |
ForEach-Object {$_."data-frid"} |
ForEach-Object {
$count++
$data = @{frid=$_};
$v=Invoke-WebRequest -Uri 'https://ecchi.iwara.tv/api/user/friends' -WebSession $session -Method $IWARA_HTTP_METHOD -Body $data
}
}
Write-Host "$count requests processed"
Pause
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment