aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/zoho/webview.js
blob: 7c833a33f58de1875087680554a0690a5395b7e1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
const _path = _interopRequireDefault(require('path'));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

module.exports = (Ferdi) => {
  const getMessages = () => {
    Ferdi.injectJSUnsafe(_path.default.join(__dirname, 'webview-unsafe.js'));
  };

  //Zoho uses different URLs for different regions. Find out which region the account belongs to and redirect to the correct URL.
  const redirectRegion = () => {
    if (window.location.href === "https://www.zoho.com/mail/login.html") {
      const btn = document.querySelectorAll(".access-apps");
      if (btn.length > 0) {
        window.location.assign(btn[0].href + "zm/");
      }
    }
  }

  window.addEventListener('load', redirectRegion);
  Ferdi.loop(getMessages);

};