24 Matching Annotations
  1. Jun 2023
  2. Oct 2022
  3. Aug 2022
    1. ```js (function () { var html = document.documentElement.innerHTML;

      /** 
       * the iframe's onload event is triggered twice: once when appending it to the document, 
       * and once when the form finishes submitting and the new URL is loaded 
       */
      var loaded = 0;
      
      var iframe = document.createElement('iframe');
      
          // unique name, to make sure we don't create any conflicts with other elements on the page
          iframe.name = 'bookmarklet-' + Math.floor((Math.random() * 10000) + 1);
          iframe.style.display = 'none';
      
          iframe.onload = function () {
              // remove the iframe from the document on the second firing of the onload event
              if (++loaded == 1) {
                  return;
              }
      
              // you can also alert('Done!') here :)
              document.body.removeChild(iframe);
          };
      
      var form = document.createElement('form');
          form.method = "POST";
          form.action = "http://requestb.in/sbnc0lsb?nocache=" + Math.random();
          form.target = iframe.name;
      
      var textarea = document.createElement('textarea');
          textarea.name = 'source';
          textarea.value = html;
      
      form.appendChild(textarea);
      iframe.appendChild(form);
      
      document.body.appendChild(iframe);
      
      form.submit();
      

      })(); ```

  4. Apr 2022
  5. Feb 2019
  6. Oct 2017
    1. Hypothes.is front page

      I took some time to find this page...

      If you had made your account and logged in, then the front page turned to be "How to get started" page with only the link to Chrome extension.

      If you want to use Firefox bookmarklet, you do as follows: 1) If you had logged in, sign out 2) click GET STARTED button 3) find the link to "other browsers" in the line with number ➁

      I think it's misleading. The better way for me to put the link to "other browsers" in the "How to get started" page for the users who already logged in. Thank you!

  7. Oct 2015
    1. Also, I would like to create a roll your own PS bookmarklet builder that will allow one to specify for example where the anchors should be placed (beginning/end of paragraph), whether to use numbers/graphics, link/alink/vlink color(s), option to show/hide certain elements or include toggle button, etc.

      I think Hypothes.is folks can utilize this idea. Allow users to roll their own bookmarklet. (Bookmarklet's are not dead yet :)

  8. Apr 2015
    1. hypothesis.js

      hypothesis.js is injected into the page by embed.js using either the browser's plugin API or (in the case of the bookmarklet) the DOM API. (embed.js was in turn injected by the browser plugin or bookmarklet).

      hypothesis.js is the "bootstrap" code that connects up and starts the various components of the Hypothesis app.

    1. var baseUrl = document.createElement('link'); baseUrl.rel = 'sidebar'; baseUrl.href = '{{ app_uri or request.resource_url(context, 'app.html') }}'; baseUrl.type = 'application/annotator+html'; document.head.appendChild(baseUrl);

      Finally, we inject a <link rel="sidebar" type="application/annotator+html" href=".../app.html"> into the <head> of the document. This is the HTML page for the contents of the sidebar/iframe. This link will be picked up by hypothesis.js later.

    2. if (resources.length) { var url = resources.shift(); var ext = url.split('?')[0].split('.').pop(); var fn = (ext === 'css' ? injectStylesheet : injectScript); fn(url, next); }

      This loop is where we actually call injectScript() or injectStylesheet() on each of the resource URLs defined above.

    3. var injectStylesheet = inject.stylesheet || function injectStylesheet(href, fn) {

      hypothesisInstall() will use the inject.stylesheet() function passed in to it to inject stylesheets into the page or, if no function was passed in, it'll fallback on the default function defined inline here.

      The default method just uses the DOM's appendChild() method, but this method may fail if the site we're trying to annotate uses the Content Security Policy.

      That's why when we're using one of the browser plugins rather than the bookmarklet, we pass in the browser API's method for injecting a stylesheet instead.

      This is why the bookmarklet doesn't currently work on GitHub, for example, but the Chrome plugin does.

    4. embed.js

      embed.js is responsible for "embedding" the different components of the Hypothesis frontend application into the page.

      First, either bookmarklet.js or one of the browser plugins injects a <script> tag to embed.js into the page, then embed.js runs.

      This way the code in embed.js is shared across all bookmarklets and browser plugins, and the bookmarklets and plugins themselves have very little code.