; WebOne Configuration File
; Its format is like INI, but also can contain raw lists inside some sections.
; For binary options use: 1/0, y/n, yes/no, on/off, enable/disable, true/false.
; Help and documentation: https://github.com/atauenis/webone/wiki/Configuration-file

[Server]
; Server settings
; Port=Port to listen
; DefaultHostName=Proxy's host name (set to valid IP or domain name for use with/on Linux or macOS)
; Authenticate=Set if the proxy needs to be protected by "login:password" or leave blank
; OutputEncoding=Codepage for patched output content (list of available: http://localhost/!codepages/)
; HideClientErrors=Hide client connection error messages in log (for Netscape 3 PNG rejections)
; SearchInArchive=Enable searching for unavailable pages (Server Not Found or 404) in archive.org
; ShortenArchiveErrors=Enable shortening of 404s on web.archive.org to get off large scipts and images
; SecurityProtocols=Forcely set SSL/TLS protocols that can be used for retrieving web content
; ValidateCertificates=Break network operations when the remote TLS certificate is bad
; UserAgent=Override user-agent string to fetch uncut content
; TemporaryDirectory=Directory which should be used for temporary files (%TEMP%, $TEMP or any other)
; LogFile=Path to server log file. To use a log file without erasing, use AppendLogFile instead
; DisplayStatusPage=Set status page display style (no, short, full)
Port=8080
DefaultHostName=%HostName%
;Authenticate=login:password
;OutputEncoding=AsIs
;OutputEncoding=Windows
;OutputEncoding=DOS
OutputEncoding=Apple
HideClientErrors=yes
SearchInArchive=yes
ShortenArchiveErrors=yes
;SecurityProtocols=4032
ValidateCertificates=yes
UserAgent=%Original% WebOne/%WOVer%
;UserAgent=Mozilla/4.75 [en] (Windows NT 5.0; U)
TemporaryDirectory=%TEMP%
LogFile=%SYSLOGDIR%/webone.log
;AppendLogFile=%SYSLOGDIR%/webone.log
DisplayStatusPage=short


[ForceHttps]
; list of domains that should be always accessed via HTTPS
phantom.sannata.org
www.phantom.sannata.org
login.vk.com
m.vk.com
vk.com
webdav
webdav.yandex.ru
web.archive.org
googlevideo.com
commondatastorage.googleapis.com
rutracker.org
www.vogons.org


[InternalRedirectOn]
; list of URLs where 302 redirections should be handled at all by WebOne, not browser
; (Empty)


[ForceUtf8]
; list of URLs that should be always downloaded as UTF-8
^http://.*yandex.ru/


[TextTypes]
; list of MIME type mask that means files which should be patched during transfer
text/
javascript
json
cdf
x-netcdf
xml


; Sets of traffic edits
[Edit:jquery.min.js]
; Redirect all requests to jQuery of versions other than 1.9.1 to Google's CDN with
; the last version supported by Firefox 3.6. This will not touch WebDAV traffic.
; Title: RegExp mask of URLs that should be touched by this Set of edits.
; IgnoreUrl: RegExp mask(s) of URLs which should NOT be touched by this Set of edits.
; OnUrl: additional URL RegExp masks not listed in section's title.
; AddRedirect: the destination URL of this redirection rule
IgnoreUrl=1.9.1
IgnoreUrl=webdav
OnUrl=jquery2.js
OnUrl=jquery-[0-9]*\.[0-9]*\.[0-9]*\.min\.js
IgnoreUrl=webdav
AddRedirect=http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js

[Edit:jquery-ui.js]
; similar to jquery main file, but for jquery-ui
IgnoreUrl=1.9.1
IgnoreUrl=webdav
OnUrl=jquery-ui[a-z0-9\.\-]*.js
AddRedirect=http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.1/jquery-ui.min.js

[Edit:bootstrap.min.js]
IgnoreUrl=2.3.1
IgnoreUrl=webdav
AddRedirect=http://maxcdn.bootstrapcdn.com/bootstrap/2.3.1/js/bootstrap.min.js


[Edit:(^http://.*/styles/prosilver/theme/)(.*)]
; downgrade stylesheets of phpBB proSilver skin to version 3.0 on old browsers
OnHeader=User-Agent: .*MSIE [3456]
OnHeader=User-Agent: Mozilla/3
OnHeader=User-Agent: Mozilla/4
IgnoreUrl=webdav
AddRedirect=http://atauenis.github.io/webone-webfixes/prosilver/theme/$2


[Edit:^http://super8russia.ning.com]
; another example of redirect, but to Wayback Machine
; IgnoreUrl is not need here (the RegExp used here is quite detailed)
AddRedirect=http://web.archive.org/web/2010/%URL%


[Edit::443]
; another example of redirect, but with remove of 443 port (final murder of SSL)
; the redirect is internal (hidden, seamless) so we're using AddInternalRedirect here
AddInternalRedirect=%UrlNoPort%

; Dead hosting providers
[Edit:^(http://www\.|http://)geocities.com/]
AddRedirect=http://web.archive.org/web/2008/%URL%

[Edit:^http://web.ukonline.co.uk/]
AddRedirect=http://web.archive.org/web/2007/%URL%

[Edit:^(http://www\.|http://)narod.ru/]
AddRedirect=http://web.archive.org/web/2012/http://narod.yandex.ru/%UrlNoDomain%

[Edit:^http://narod.yandex.ru/]
AddRedirect=http://web.archive.org/web/2012/%URL%

[Edit:^http://.*.by.ru/]
IgnoreUrl=web.archive.org
AddRedirect=http://web.archive.org/web/2011/%URL%Redirect=http://web.archive.org/web/2011/%URL%


; Microsoft software interactivity
[Edit:^http://ie.search.msn.com/]
AddRedirect=http://web.archive.org/web/2000/%URL%

[Edit:^http://[a-z\.]*windowsmedia.com/]
AddRedirect=http://web.archive.org/web/2002/%URL%

[Edit:^http://go.microsoft.com/]
AddRedirect=http://web.archive.org/web/2005/%URL%

[Edit:^(http://www\.|http://)microsoft.com/isapi/]
AddRedirect=http://web.archive.org/web/2005/%URL%

[Edit:^http://[a-z\.]*.windows.com/]
AddRedirect=http://web.archive.org/web/2005/%URL%

[Edit:^(http://www\.|http://)iechannelguide.com]
AddRedirect=http://web.archive.org/web/1997/%URL%

[Edit:^(http://www\.|http://)microsoft.com/IE/]
AddRedirect=http://web.archive.org/web/1997/%URL%

; WebTV
[Edit:^http://developer.webtv.net/]
AddRedirect=http://web.archive.org/web/20010118212000/%URL%

[Edit:^http://www.crosswinds.net/~lsyndicate/cara/]
AddRedirect=http://web.archive.org/web/20000815230842/%URL%

[Edit:^http://www.webtvaudio.com/]
AddRedirect=https://web.archive.org/web/20010720053557/%URL%

[Edit:^http://soweird.mine.nu/]
AddRedirect=https://web.archive.org/web/20010720053557/%URL%


[Edit:\.cdf$]
IgnoreUrl=web.archive.org
AddRedirect=http://web.archive.org/web/1998/%URL%

; YouTube playback (youtube-dl & yt.bat)
;    uncomment lines below to enable
;[Edit:^(http://www\.|http://)youtube.com/watch]
;AddRedirect=http://%Proxy%/!convert/?url=%Url%&util=yt.bat&type=video/x-ms-asf
;AddConvert=yt.bat
;AddResponseHeader=Content-Type: video/x-ms-asf

; YouTube playback (via original ViewTube)
;    uncomment lines below to enable
;[Edit:^(http://www\.|http://).*.googlevideo.com/]
;AddRedirect=http://%Proxy%/!convert/?url=%Url%&util=ffmpeg&arg=-vcodec%20wmv1%20-acodec%20wmav1%20-f%20asf&type=video/x-ms-asf



; Content patches
; Apply some edits to page's content. Here are two edits, in example:
;  1. Replace "eval()" with direct calls for IE3/4
;  2. Fix work with _tmr JS variable in inline scripts (for IE4 too)
; AddFind: the find mask.
; AddReplace: the replacement.
[Edit:^http://old-dos.ru]
AddFind=eval\(('|")(.*?)\1\)
AddReplace=$2
AddFind=var _tmr = _tmr .* \[\];
AddReplace=var _tmr = _tmr;

[Edit:.*]
OnContentType=application/x-netcdf
AddFind=HREF="http://
AddReplace=HREF="http://web.archive.org/web/1998/

[Edit:\.cdf$]
AddFind= HREF="http://
AddReplace= HREF="http://web.archive.org/web/1998/

[Edit:^http(s?)://web.archive.org/web/]
AddFind=<script src="\/\/archive.org.*Include -->
AddReplace=
AddFind=<script><!--\n     FILE.*\n-->
AddReplace=
;it's meaning that Web Archive scripts will not be delivered to client

; BBC news photo fix
[Edit:^http://www.bbc.co.uk/.*]
OnUrl=^http://www.bbc.com/.*
AddFind=<noscript><img
AddReplace=<img
AddFind=></noscript>
AddReplace=>

; Mobile VKontakte script fix
[Edit:^http://[a-zA-Z0-9\-\.]*vk.com/]
AddFind="cookie_secure":" Secure;"
AddReplace="cookie_secure":" WebOneEdited;"


; Firefox 3.5-16.0 CSS3 patches
[Edit]
OnContentType=text/css
OnHeader=User-Agent: .*rv\:(\b(1|2|3|4|5|6|7|8|9|10|11|12|13|14|15)\b\.).*Gecko
AddFind=(background-size|box-shadow|text-shadow|border-radius|border-image|column-.*|animation-.*transition|transform|linear-gradient|flex)
AddReplace=-moz-$1
AddFind=to bottom
AddReplace=top
AddFind=to top
AddReplace=bottom
AddFind=to right
AddReplace=left
AddFind=to left
AddReplace=right


[Converters]
; Whitelist of known local format converters
;    switch comments on next 2 lines to choose: tmp file or direct stdout processing
;convert %SRC% %ARG1% %DEST% %ARG2%
convert %SRC% %ARG1% %DESTEXT%:- %ARG2%
magick %SRC% %ARG1% %DEST% %ARG2%
;    line below needs ffmpeg binaries to work
ffmpeg -i pipe: %ARG1% pipe:
;    line below needs yt.bat script and youtube-dl to work (only for YouTube downloading)
yt.bat "%SRCURL%"


; PNG->GIF and WebP->GIF converting (for IE3, Netscape)
[Edit]
OnContentType=image/png
OnContentType=image/webp
OnCode=200
OnHeader=User-Agent: Mozilla/0
OnHeader=User-Agent: Mozilla/1
OnHeader=User-Agent: Mozilla/2
OnHeader=User-Agent: Mozilla/3
OnHeader=User-Agent: WebTV
IgnoreUrl=webdav
AddConvert=convert
AddConvertDest=gif
AddResponseHeader=Content-Type: image/gif

;    uncomment section below to enable JPG recompression
[Edit]
OnContentType=image/jpeg
OnContentType=image/jpg
;OnContentType=image/png
;OnContentType=image/webp
OnCode=200
IgnoreUrl=webdav
AddConvert=convert
AddConvertDest=jpg
AddConvertArg1=-quality 35 -resize 640x480>
AddResponseHeader=Content-Type: image/jpeg


; Enforce security & spoof CORS
[Edit]
IgnoreUrl=webdav
AddHeader=upgrade-insecure-requests: 1
AddHeader=sec-fetch-mode: navigate
AddHeader=sec-fetch-site: same-origin
AddHeader=sec-fetch-user: ?1
;AddResponseHeader=Access-Control-Allow-Origin: http://%UrlDomain%

; Disable CORS and SRI checks
[Edit]
OnContentType=html
IgnoreUrl=webdav
AddFind=integrity=
AddReplace=disable-integrity=
AddFind=crossorigin=
AddReplace=disable-crossorigin=

; Remove CSP (mostly due to 'upgrade-insecure-requests')
[Edit]
IgnoreUrl=webdav
AddFind=<meta http-equiv="Content-Security-Policy"[a-zA-Z\ 0-9\'\"\-\=\;\*\:]*>
AddReplace=<!--Content-Security-Policy meta isn't need through WebOne-->


; HTTP request&response header saving (dumping)
;    uncomment section below to enable header dumping
;[Edit]
;AddHeaderDumping=dump-%Url%.log


; Ad blocking
;    uncomment section below to enable ad blocking
[Edit]
OnUrl=^http://mc.yandex.ru
OnUrl=^http://yandex.net/banner/
OnUrl=^http://st.yandexadexchange.net
OnUrl=^http://rareru.ru
OnUrl=^http://ad.mail.ru
OnUrl=^http://utarget.ru
OnUrl=^http://betweendigital.com
OnUrl=^http://marketgid.com
OnUrl=^http://googlesyndication.com
OnUrl=^http://doubleclick.net
OnUrl=^http://ads.google.com
OnUrl=/adsense
OnUrl=/adword
OnUrl=adriver.ru
AddRedirect=file://ROMCache/spacer.gif



[Include:%WOConfigDir%/*.conf]