eklem / nowcontent.xyz

Create bookmarklets for sending content / pages to service [xyz]
MIT License
7 stars 1 forks source link

jsonbin.io as storage #28

Closed eklem closed 5 years ago

eklem commented 5 years ago

Make it use Zapier -> JSONbin.io for storing what's bookmarked. Will need a way to add/define and store the following:

Store in indexedDB.

eklem commented 5 years ago

Can't be IndexedDB, because we don't have access to it when on other pages. Needs to be generated HTML. Could be from nowsearch.xyz ?

eklem commented 5 years ago

Hmm, no. Can't store a secret key somewhere in the open. Only need the bookmark in the browser to store/hold the secret keys. Add them when generating the bookmarklet for adding to the browser bookmarks? Maybe IndexedDB is an okay idea after all. Need to be on nowsearch.xyz to add the bookmark. There, the keys are picked up from IndexedDB. When you want to add another browser, you need to add the keys (for now).

eklem commented 5 years ago

Won't work for several reasons: Zapier doesn't seem to accept cross-origin script (maybe possible to get working, maybe not) and jsonbin.io only holding one object at a time.

eklem commented 5 years ago

Actually, I could:

eklem commented 5 years ago

Check if creating a bin for each bookmark will work. Create them under a collection so all bins can be retrieved in one go.

eklem commented 5 years ago

Working! To get data out, you have to do two steps: 1: Query the collection for bins with this javascript:

let req = new XMLHttpRequest();

req.onreadystatechange = () => {
  if (req.readyState == XMLHttpRequest.DONE) {
    console.log(req.responseText);
  }
};

req.open("GET", "https://api.jsonbin.io/e/collection/<COLLECTION_ID>/all-bins", true);
req.setRequestHeader("secret-key", "<SECRET_KEY>");
req.send();

2: loop through and query every bin and then index