<?xml version="1.0" encoding="utf-8"?>
<service name="blogger"
         version="$Id: blogger.xml 20509 2008-10-04 22:46:53Z richard $"
         xmlns="http://www.flock.com/web-detective#">

  <strings>
    <string name="homePageURL" locale="default">
      <![CDATA[http://www.blogger.com/]]>
    </string>
  </strings>

  <detect type="signup">
    <url domain="google.com">
      <path contains="/accounts/NewAccount" />
      <querystring contains="service=blogger" />
    </url>
    <form>
      <xpath name="username" extract="value">
        <![CDATA[//input[@name="Email"]]]>
      </xpath>
      <xpath name="password" extract="value">
        <![CDATA[//input[@type="password"][@name="PasswdAgain"]]]>
      </xpath>
    </form>
  </detect>

  <detect type="signup">
    <url domain="google.com">
      <path contains="/accounts/CreateAccount" />
      <querystring contains="service=blogger" />
    </url>
    <form>
      <xpath name="username" extract="value">
        <![CDATA[//input[@name="Email"]]]>
      </xpath>
      <xpath name="password" extract="value">
        <![CDATA[//input[@type="password"][@name="PasswdAgain"]]]>
      </xpath>
    </form>
  </detect>
  
  <detect type="login">
    <url domain="google.com">
      <path contains="/accounts/ServiceLogin" />
      <querystring contains="service=blogger" />
    </url>
    <form>
      <xpath name="username" extract="value">
        <![CDATA[//input[@id="Email"]]]>
      </xpath>
      <xpath name="password" extract="value">
        <![CDATA[//input[@id="Passwd"]]]>
      </xpath>
    </form>
  </detect>

  <detect type="login">
    <url domain="blogger.com">
      <path contains="/start" />
    </url>
    <form>
      <xpath name="username" extract="value">
        <![CDATA[//input[@id="Email"]]]>
      </xpath>
      <xpath name="password" extract="value">
        <![CDATA[//input[@id="Passwd"]]]>
      </xpath>
    </form>
  </detect>

  <!-- Old Blogger -->
  <detect type="loggedin">
    <conditions>
      <url domain="blogger.com"/>
      <document>
        <xpath><![CDATA[//div[@id="header"]/div[@id="h2"]/div[@id="h3"]/p[@id="user"]]]></xpath>
      </document>
    </conditions>
  </detect>

  <!-- Blogger beta -->
  <detect type="loggedin">
    <conditions>
      <url domain="blogger.com"/>
      <document>
        <xpath><![CDATA[//div[@id="header"]/div[@id="h2"]/div[@id="h3"]/div[@id="global-info"]]]></xpath>
      </document>
    </conditions>
  </detect>

  <detect type="loggedout">
    <url domain="blogger.com">
      <path equals="/start" />
    </url>
  </detect>

  <detect type="loggedout">
    <url domain="google.com">
      <path contains="/accounts/ServiceLogin" />
      <querystring contains="service=blogger" />
    </url>
  </detect>

  <!-- For Google Accounts that use Gmail addresses for login -->
  <detect type="accountinfo">
    <conditions>
      <url domain="blogger.com"/>
      <xpath>
        <![CDATA[//div[@id="header"]//div[@id="global-info"]/span/text()]]>
        <regexp>
          <![CDATA[/.+@g(?:|oogle)mail\.com/]]>
        </regexp>
      </xpath>
    </conditions>
    <results>
      <xpath>
        <![CDATA[//div[@id="header"]//div[@id="global-info"]/span/text()]]>
        <regexp re1="email" re2="accountid">
          <![CDATA[/((.+)@g(?:|oogle)mail\.com)/]]>
        </regexp>
      </xpath>
      <xpath name="avatarURL" extract="attribute:src">
        <![CDATA[//img[@alt="My Photo"]]]>
      </xpath>
    </results>
  </detect>

  <!-- For older Google Accounts that don't use Gmail addresses for login.
       Checking for a Gmail address should always happen before this rule -->
  <detect type="accountinfo">
    <conditions>
      <url domain="blogger.com"/>
      <xpath>
        <![CDATA[//div[@id="header"]//div[@id="global-info"]/span/text()]]>
      </xpath>
    </conditions>
    <results>
      <xpath>
        <![CDATA[//div[@id="header"]//div[@id="global-info"]/span/text()]]>
        <regexp re1="email" re2="accountid">
          <![CDATA[/((.+))/]]>
        </regexp>
      </xpath>
      <xpath name="avatarURL" extract="attribute:src">
        <![CDATA[//img[@alt="My Photo"]]]>
      </xpath>
    </results>
  </detect>

<!--  
  <detect type="loggedin">
    <conditions>
      <url domain="google.com"><path contains="accounts"/></url>
      <document>
        <xpath><![CDATA[//table[1]/tbody/tr[1]/td/font/a[4]/text()[contains(.,"Sign Out")]]]></xpath>
      </document>
    </conditions>
  </detect>
-->
  <detect type="loggedin">
    <conditions>
      <url domain="blogger.com"></url>
      <document>
        <regexp>
          <![CDATA[/<a href="\/logout.g">/]]>
        </regexp>
      </document>
    </conditions>
  </detect>
  
  <!-- For Google Accounts that use Gmail addresses for login -->
  <detect type="accountinfo">
    <conditions>
      <url domain="google.com"><path contains="accounts"/></url>
      <document>
        <xpath>
          <![CDATA[//table[1]/tbody/tr[1]/td/font/b/text()]]>
          <regexp re1="email" re2="accountid">
            <![CDATA[/((.+)@g(?:|oogle)mail\.com)/]]>
          </regexp>
        </xpath>
      </document>
    </conditions>
  </detect>

  <!-- For older Google Accounts that don't use Gmail addresses for login.
       Checking for a Gmail address should always happen before this rule -->
  <detect type="accountinfo">
    <conditions>
      <url domain="google.com"><path contains="accounts"/></url>
      <document>
        <xpath>
          <![CDATA[//table[1]/tbody/tr[1]/td/font/b/text()]]>
          <regexp re1="email" re2="accountid">
            <![CDATA[/((.+))/]]>
          </regexp>
        </xpath>
      </document>
    </conditions>
  </detect>
    
  <detect type="changepassword">
    <url domain="google.com">
      <path contains="accounts/EditPasswd" />
    </url>
    <document>
      <regexp re1="username">
        <![CDATA[/getUserName\("([^"]*)"\)/]]>
      </regexp>
    </document>
    <form>
      <xpath name="password" extract="value">
        <![CDATA[//input[@type="password"][@name="PasswdAgain"]]]>
      </xpath>
   </form>
  </detect>

  <detect type="ownsDocument">
    <url domain="blogger.com" />
  </detect>

  <detect type="ownsDocument"><!-- Login page for Blogger Beta -->
    <url domain="google.com">
      <querystring contains="service=blogger" />
    </url>
  </detect>

</service>
