From 8f9c22fdaff4a9b61cf1dab4f25378e2d169b3a8 Mon Sep 17 00:00:00 2001 From: vantezzen Date: Mon, 3 Feb 2020 12:59:27 +0100 Subject: Add info about Franz accounts in Ferdi Todos --- src/features/todos/preload.js | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/features/todos/preload.js b/src/features/todos/preload.js index d1838e0d6..0a1183030 100644 --- a/src/features/todos/preload.js +++ b/src/features/todos/preload.js @@ -21,3 +21,30 @@ ipcRenderer.on(IPC.TODOS_HOST_CHANNEL, (event, message) => { debug('Received host message', event, message); hostMessageListener(message); }); + +if (location.href === 'https://app.franztodos.com/login/') { + // Insert info element informing about Franz accounts + const infoElement = document.createElement('p'); + infoElement.innerText = `You are using Franz\'s official Todo Service. +This service will only work with accounts registered with Franz - no Ferdi accounts will work here! +If you do not have a Franz account you can change the Todo service by going into Ferdi's settings and changing the "Todo server". +You can choose any service as this Todo server, e.g. Todoist or Apple Notes.`; + + // Franz Todos uses React. Because of this we can't directly insert the element into the page + // but we have to wait for React to finish rendering the login page + let numChecks = 0; + const waitForReact = setInterval(() => { + const textElement = document.querySelector('p'); + if (textElement) { + clearInterval(waitForReact); + textElement.parentElement.insertBefore(infoElement, textElement); + } else { + numChecks += 1; + + // Stop after ~10 seconds. We are probably not on the login page + if (numChecks > 1000) { + clearInterval(waitForReact); + } + } + }, 10); +} -- cgit v1.2.3-54-g00ecf