Skip to content

Commit

Permalink
Merge pull request #1152 from RedBaron2/patch-5
Browse files Browse the repository at this point in the history
(wps-office-free) update to read JS rendered page in posh
  • Loading branch information
AdmiringWorm authored Dec 7, 2018
2 parents 9f5cd5b + 48ffa77 commit 1a2b34d
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 37 deletions.
37 changes: 0 additions & 37 deletions automatic/wps-office-free/_update.ps1

This file was deleted.

24 changes: 24 additions & 0 deletions automatic/wps-office-free/update.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import-module au
. ".\update_helper.ps1"

function global:au_SearchReplace {
@{
".\tools\chocolateyInstall.ps1" = @{
"(^[$]version\s*=\s*)('.*')" = "`$1'$($Latest.Version)'"
"(^\s*packageName\s*=\s*)('.*')" = "`$1'$($Latest.PackageName)'"
"(^\s*url\s*=\s*)('.*')" = "`$1'$($Latest.URL32)'"
"(^\s*checksum\s*=\s*)('.*')" = "`$1'$($Latest.Checksum32)'"
"(^\s*checksumType\s*=\s*)('.*')" = "`$1'$($Latest.ChecksumType32)'"
}
}
}

function global:au_GetLatest {
$streams = [ordered] @{
wps = Get-JavaSiteUpdates -package "wps-office-free" -Title "WPS Office Free"
}

return @{ Streams = $streams }
}

update
71 changes: 71 additions & 0 deletions automatic/wps-office-free/update_helper.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@


function Get-PackageName() {
param(
[string]$a
)

switch -w ( $a ) {

'wps-office-free' {
$PackageUrl = "https://www.wps.com/en-US/office/windows/"
}

}

return $PackageUrl

}

function Get-JavaSiteUpdates {
# $wait number can be adjusted per the package needs
param(
[string]$package,
[string]$Title,
[string]$padVersionUnder = '10.2.1',
[string]$wait = 4
)

$OS_caption = ( Get-CimInstance win32_operatingsystem -Property Caption )
$check = @{$true=$true;$false=$false}[ ( $OS_caption -match 'Server' ) ]
$regex = '([\d]{0,2}[\.][\d]{0,2}[\.][\d]{0,2}[\.][\d]{0,5})'
$url = Get-PackageName $package
$ie = New-Object -comobject InternetExplorer.Application
$ie.Navigate2($url)
$ie.Visible = $false
while($ie.ReadyState -ne $wait) {
start-sleep -Seconds 20
}
if ( $check ) {
$url32 = $ie.Document.IHTMLDocument3_getElementsByTagName("a") | % { $_.href } | where { $_ -match $regex } | select -First 1
} else {
$url32 = $ie.Document.getElementsByTagName("a") | % { $_.href } | where { $_ -match $regex } | select -First 1
}

foreach ( $_ in $ie.Document.getElementsByTagName("a") ) {
$url = $_.href;
if ( $url -match $regex) {
$yes = $url | select -last 1
$version = $Matches[0]
$the_match = $yes -match( $rev_regex );
$revision = $Matches[0];
break;
}
}
$ie.quit()
if ($package -match 'wps') {
$version = $version
} else {
$version = $version + $revision
}


@{
PackageName = $package
Title = $Title
fileType = 'exe'
Version = Get-FixVersion $version -OnlyFixBelowVersion $padVersionUnder
URL32 = $yes
}

}
3 changes: 3 additions & 0 deletions automatic/wps-office-free/wps-office-free.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"wps": "10.2.0.7549"
}

0 comments on commit 1a2b34d

Please sign in to comment.