From 2c5ff097b8507722d7dada740bfbd0e53a83a78d Mon Sep 17 00:00:00 2001 From: Caesar2011 Date: Mon, 29 Jan 2024 08:48:33 +0100 Subject: [PATCH] Initial Commit --- .idea/.gitignore | 8 ++++ .idea/finanzfluss-addon.iml | 12 +++++ .idea/modules.xml | 8 ++++ .idea/vcs.xml | 6 +++ compile.sh | 1 + finanzfluss-addon.zip | Bin 0 -> 2017 bytes src/background.js | 8 ++++ src/contentScript.js | 89 ++++++++++++++++++++++++++++++++++++ src/manifest.json | 12 +++++ 9 files changed, 144 insertions(+) create mode 100644 .idea/.gitignore create mode 100644 .idea/finanzfluss-addon.iml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100755 compile.sh create mode 100644 finanzfluss-addon.zip create mode 100644 src/background.js create mode 100644 src/contentScript.js create mode 100644 src/manifest.json 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 0000000000000000000000000000000000000000..a0acbe0619746dafd627a7087f82ca06c4857790 GIT binary patch literal 2017 zcmaJ?2{hDeAO6pbv5d8et58ZLS+0waCCivWwlSeewlR${Tw|HBgTf?|k3a(fRIq&+{(lyyrRR_xyh6dC)cxK1l!o1OX7r z7<)B$V~))S0DQs#AOXk$_&_q1K&GCrf$3tj@FaYA4f$+ZX zZpAJa1K(LmMsrFJs0EDY|IC!6qx&TpnCI%{^N$!VuGhWBPqS(I+8^4hbkw#NqkQH! z;H@9e{D{1HrDWupA>B$X9)u&~Us3i)zs;se1|;YXh;(T89!YH%Oby1#H)27j3{hR- z-rMzTX`~`cLB$vRhwgs#ed%?V!VzD?K+pr4<0V}1wie;CW~mq3((QqSrt#<%i2-&I0EWsEO@rn9R&u49%DIq~9Lqmd^5{Fu}H-wG4J2IDV^1?kKkqtggaMa(&HB z+o0sY{72>WUq78etgUJWiNkE~TR;!gPo!Dz!)8lu{UD8L7cOGyw?+Ie_MAI6<+fYrd5ap2$pD3$) zQWb7g;Ou!r=a$)=gT}ZSQ-03ON8%a=1LYzR7dbTO)H?985)jjtQXg^GaXH|d)|-U9Ug4HP(PYU2TxY?=-(nM_WfFtnSIdt zs>!E*QiGbnkf1R>(5~J=F*ueUFR?a~<(P{3&&ht@9qzMKyp1#>av)Cyg-c*jvn_(%G zz-B`#)YqyN-PM@PmTdQ()#64MuV&RFr6Bhd6XAI$#{|BY)@d1Bdxe)5jK`&|C!|^9 z>$2X{R8GywvU%|@X6CM*TG3Qjfgw76mMlK@<5W*WLPTRypeiY_yM4sakxQDhg@?qt z(~tG{CZ1&-TD>=r?iEHjl}Bc~1%-(ey=0v#C>)FO=u2JDm^6>mqSP(L=I9z0eU2K9 zjDev4YkleF#@Hu7RX`2T2-QIVAj-48034a*L!j)sULg5z-)nWOB)s8akMG$f+lgJ% zl!)hKJ($guOfvL#y9|U91yw>*{7CF`M;JljU+@opwVsX&9Jb9!l<23ZUo<`M;N>V| zXH(V|mlG*obKkPyS#+hJMXuwQs;_j;C~{d3K?UEokWf$@I)x$VOIoi9NwQ8 z5*SLp^dIvNU8o==^RPz*=Oi|)K~oao{DeFqrjquPsgywQyi*XIOVx%^O^}uz3hI?L=Rh7p`W{DRXl`wGR;L+6^Dd+#!m`PrwtV^VcC`Vt9dSkS zLc$MStrDv+e63C97Ssp!36Bq$*1tx}Sr1=fro$?iJ(wcnE0F2G-U>2oHbl`jAn;+x z{|mGOys`j**I*zwcK7yeyg~mRZ+oiyn)TaR`I_|$FFf~54v%toa{htxTjjr|1o(ly Zec(~<_Td{!DDNu(KzM75cXs~$`WFvHXSe_W literal 0 HcmV?d00001 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