commit 2c5ff097b8507722d7dada740bfbd0e53a83a78d Author: Caesar2011 Date: Mon Jan 29 08:48:33 2024 +0100 Initial Commit diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/finanzfluss-addon.iml b/.idea/finanzfluss-addon.iml new file mode 100644 index 0000000..24643cc --- /dev/null +++ b/.idea/finanzfluss-addon.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..7da0eb2 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/compile.sh b/compile.sh new file mode 100755 index 0000000..9914d91 --- /dev/null +++ b/compile.sh @@ -0,0 +1 @@ +cd src && rm -f .../finanzfluss-addon.zip && zip -r ../finanzfluss-addon.zip * \ No newline at end of file diff --git a/finanzfluss-addon.zip b/finanzfluss-addon.zip new file mode 100644 index 0000000..a0acbe0 Binary files /dev/null and b/finanzfluss-addon.zip differ diff --git a/src/background.js b/src/background.js new file mode 100644 index 0000000..429ec90 --- /dev/null +++ b/src/background.js @@ -0,0 +1,8 @@ +function logURL(requestDetails) { + console.log(`Loading: ${requestDetails.url}`); +} + +browser.webRequest.onBeforeRequest.addListener(logURL, { + urls: [""], + +}); diff --git a/src/contentScript.js b/src/contentScript.js new file mode 100644 index 0000000..39bd1cc --- /dev/null +++ b/src/contentScript.js @@ -0,0 +1,89 @@ +// contentScript.js + +const styleElement = document.createElement('style'); +// language=CSS +styleElement.textContent = ` +.ff-addon-title { + margin: 0; + font-weight: 600; + line-height: 30px; + font-size: 18px; +} + +.ff-addon-title-container { + margin-bottom: 12px; + width: 100%; +} + +.ff-addon-hr { + margin: 0px 0px 16px; + border-width: 0px 0px thin; + border-style: solid; + border-color: rgb(54, 58, 61); +} + +.ff-addon-container { + margin-bottom: 18px; +}`; +document.head.appendChild(styleElement); + +const scriptElement = document.createElement('script'); +// language=JavaScript +scriptElement.textContent = ` + async function doJsonFetch(token, method, url) { + const res = await fetch(url, + { + method: method, + credentials: 'same-origin', + headers: { + "Authorization": "Bearer "+token + } + }) + return await res.json() + } + + async function onButtonClick() { + const loginToken = localStorage.getItem('LOGIN_TOKEN'); + const jsonToken = loginToken && JSON.parse(loginToken); + if (!jsonToken?.access_token) { + console.error("No access token found!", jsonToken) + return; + } + const householdBooks = await doJsonFetch(jsonToken?.access_token, "GET", "https://rentablo.de/api/v1/accounts/selectGroups/householdBook?fallbackAccountType[]=02_cash&excludeManuallyMaintainedFallbackAccounts=true") + console.log(householdBooks) + const accountIds = householdBooks.accountIds + const accountIdsQuery = "accountId[]="+accountIds.join("&accountId[]=") + const transactions = await doJsonFetch(jsonToken?.access_token, "GET", "https://rentablo.de/api/v1/transactions?"+accountIdsQuery+"&includeAdjustingEntries=false&skipManuallyCreatedTransactions=true&minDate=2024-01-01&maxDate=2024-01-31&order=date+desc&perPage=5000") + console.log(transactions) + } +`; +document.head.appendChild(scriptElement); + +let parent +const paragraphs = document.getElementsByTagName('p'); +for (let i = 0; i < paragraphs.length; i++) { + if (paragraphs[i].textContent.includes('Transaktionen')) { + parent = paragraphs[i].parentNode.parentNode; + break; // Stop searching once found + } +} + +const configDiv = document.getElementById("configDiv") || document.createElement("div") +configDiv.remove() +// language=HTML +configDiv.innerHTML = ` +
+

Konfiguriere Deine Zuordnungen

+
+
+
+ +
+` +configDiv.id = "configDiv" +configDiv.className = "MuiBox-root ff-addon-container" + +parent.parentNode.insertBefore(configDiv, parent) + diff --git a/src/manifest.json b/src/manifest.json new file mode 100644 index 0000000..c5a5410 --- /dev/null +++ b/src/manifest.json @@ -0,0 +1,12 @@ +{ + "manifest_version": 3, + "name": "Finanzfluss", + "version": "1.0", + "permissions": ["webRequest", "cookies", "activeTab", "scripting", "https://rentablo.de", "https://www.finanzfluss.de"], + "content_scripts": [ + { + "matches": [""], + "js": ["contentScript.js"] + } + ] +} \ No newline at end of file