#!/bin/bash

  # Set build configuration in Makefile.defaults
  for opt in \
    NETSURF_UA_FORMAT_STRING='"NetSurf/%d.%d (%s; Arch Linux)"' \
    NETSURF_USE_DUKTAPE=YES
  do
    setconf Makefile.defaults "$opt"
  done

  # remove non-privacy search engines
  sed -i '\|Google|d
          \|Yahoo|d
          \|Bing|d
          \|Business.com|d
          \|Omgili|d
          \|BBC News|d
          \|Ubuntu Packages|d
          \|Ask[.]com|d
          \|Answers.com|d
          \|Youtube|d
          \|AeroMp3|d
          \|AOL|d
          \|Baidu|d
          \|Amazon|d
          \|Ebay|d
          \|IMDB|d
          \|ESPN|d
          s|DuckDuckGo|DuckDuckGo HTML|
          s|duckduckgo[.]com|duckduckgo.com/html|
          s|duckduckgo[.]com/html/favicon.ico|duckduckgo.com/favicon.ico|
          s|seeks-project.info|seeks.fr|g
         ' frontends/riscos/appdir/Resources/SearchEngines \
           resources/SearchEngines
  sed -i '\|readable name such as| s|google|duckduckgo|
          \|readable name such as| s|yahoo|seeks|
          \|host address such as www[.]google[.]com| s|google[.]com|duckduckgo.com/html|
          s|google[.]com?search=%s|duckduckgo.com/html/?q=%s|
          \|return strdup| s|google[.]com|duckduckgo.com/html|
          \|return strdup| s|google|duckduckgo|
          \|return strdup| s|duckduckgo[.]com/html/favicon[.]ico|duckduckgo.com/favicon.ico|
          s|www[.]google[.]com/search?q=%s|duckduckgo.com/html/?q=%s|
         ' desktop/searchweb.c
  sed -i 's|google[.][.a-z]\{0,6\}/search|duckduckgo.com/html/search|
          s|Google-Suche|DuckDuckGo HTML|
          s|Google Search|DuckDuckGo HTML|
          s|Ricerca Google|DuckDuckGo HTML|
          s|Google検索|DuckDuckGo HTML|
          \|BBC News|d
          \|Reuters|d
          \|CNN|d
          \|Slashdot|d
          \|Ars Technica|d
          \|The Register|d
          \|W3C|d
          s|google[.][.a-z]\{0,6\}|duckduckgo.com/html|
          s|Google|DuckDuckGo HTML|
          s|[.a-z]\{0,4\}yahoo[.]co[.a-z]\{0,4\}|www.seeks.fr|
          s|Yahoo!|Seeks|
          \|IMDB|d
          s|The Icon Bar|Creative Commons|
          s|www[.]iconbar[.]com|creativecommons.org|
          s|ROOL|Dictionary.com|
          s|www[.]riscosopen[.]org|dictionary.reference.com|
          \|riscos.info|d
         ' frontends/riscos/appdir/Resources/de/welcome.html\,faf \
           frontends/riscos/appdir/Resources/en/welcome.html\,faf \
           frontends/riscos/appdir/Resources/it/welcome.html\,faf \
           frontends/riscos/appdir/Resources/ja/welcome.html\,faf \
           frontends/riscos/appdir/Resources/nl/welcome.html\,faf
  sed -i 's|Google|DuckDuckGo HTML|
         ' frontends/amiga/dist/NetSurf.guide
  # patch and remove anything that's left
  patch -p1 -i ../remove_nonprivacy_options.patch

# To remove some residual google instances

sed -i 's|"Google|www.google.com|http://duckduckgo.com/html/?q=%s|http://www.google.com/favicon.ico|\n"|"DuckDuckGo HTML|www.duckduckgo.com|http://duckduckgo.com/html/?q=%s|http://www.duckduckgo.com/favicon.ico|\n"|g' desktop/searchweb.c

sed -i 's|<form method="get" action="http://www\.google\.co\.uk/search">|<form method="get" action="https://html\.duckduckgo\.com/html/">|g' resources/en/welcome.html

sed -i 's|<input type="submit" value="Google Search" name="btnG">|<input type="submit" value="DuckDuckGo HTML Search" name="btnG">|g' resources/en/welcome.html
