--[[ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. --]] WebBanking{version = 1.02, url = 'https://dashboard.uberspace.de/login', services = {'Uberspace.de metauser'}, description = string.format( MM.localizeText("Get balance and transactions for %s"), "Uberspace.de metauser") } function SupportsBank (protocol, bankCode) return bankCode == 'Uberspace.de metauser' and protocol == ProtocolWebBanking end local usConnection = Connection() local usUsername function InitializeSession (protocol, bankCode, username, username2, password, username3) -- Split the input into email and username based on '|' local splitPos = username:find("|") if not splitPos then return "Failed to log in. Please check that the username includes both email and username separated by '|'." end usEmail = username:sub(1, splitPos - 1) usUsername = username:sub(splitPos + 1) -- Login. usUsername = usEmail html = HTML(usConnection:get('https://dashboard.uberspace.de/login')) html:xpath('//input[@name="login"]'):attr('value', usEmail) html:xpath('//input[@name="password"]'):attr('value', password) html = HTML( usConnection:request(html:xpath('//input[@name="submit"]'):click())) --if html:xpath('//input[@name="login"]'):length() > 0 then -- We are still at the login screen. --return "Failed to log in. Please check your user credentials." --end end function ListAccounts (knownAccounts) -- Return array of accounts. local account = { name = 'Uberspace ' .. usUsername, accountNumber = '1', portfolio = false, currency = 'EUR', type = AccountTypeSavings } return {account} end function RefreshAccount (account, since) function ParseAmount (amountString) local pattern = '(%-?%d+),(%d%d)' local euro, cent = amountString:match(pattern) if not euro or not cent then return nil end euro = tonumber(euro) cent = tonumber(cent) / 100 if euro < 0 then return euro - cent else return euro + cent end end -- Adjust accounting URL to include the specific username local accountingUrl = 'https://dashboard.uberspace.de/dashboard/accounting?asteroid=' .. usUsername html = HTML(usConnection:get(accountingUrl)) --[[ html = HTML(usConnection:get( 'https://dashboard.uberspace.de/dashboard/accounting')) --]] tableRows = html:xpath( '//*[@id="transactions"]//tr[count(td)=3][position()