starthq / search

Search provider API docs & integration implementations.
https://starthq.com
32 stars 26 forks source link

iCloud #24

Open olegp opened 10 years ago

ptmt commented 9 years ago

This seemed to be easy, but there is iframe with “same origin” policy and tricky redirect, so I could make this work only with chained selector to extract events from calendar (for example):

document.querySelectorAll('iframe')[0].contentWindow.document.querySelectorAll('.title').text()

I don't how I could achieve this without editing this code (from minimised libs.js):

 parseHTML: function(e) {
    var o = [];
    i.html(e.replace(/<img(('[^']*'|"[^"]*"|[^>])*)\/?>/g, "<omg$1></omg>").replace(/(<\/?)(?:script|link|meta|iframe|noscript)/g, "$1br"));
    var s;
    return angular.forEach(n.selectors, function(e, l) {
      var c = i[0].querySelectorAll(e.replace(/\bimg\b/g, "omg"));
      a && (a[l] = {
          selector: e,
          results: []
      }), s <= c.length || (s = c.length);
      for (var u = 0; s > u; u++) {
          var d = c[u];
          (o[u] || (o[u] = {
              app: n.app,
              source: t,
              searchIndex: r
          }))[l] = n.expressions[l]({
              app: n.app,
              element: d,
              term: n.term,
              $: angular.element,
              encodeURIComponent: encodeURIComponent,
              decodeURIComponent: decodeURIComponent
          }), a && a[l].results.push({
              element: d,
              result: o[u][l]
          })
      }
    }), o.length = s, o.forEach(function(e) {
      angular.extend(e, n.constants)
    }), o
    }