Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Upon looking at it more, and inspecting the bookmarklet that appears, here is the overall code structure:</p> <pre><code> javascript: (function() { var w = window, l = w.location, d = w.document, s = d.createElement('script'), e = encodeURIComponent, x = 'undefined', u = 'http://www.amazon.co.uk/wishlist/add'; if (typeof s != 'object') l.href = u + '?u=' + e(l) + '&amp;t=' + e(d.title); function g() { if (d.readyState &amp;&amp; d.readyState != 'complete') { setTimeout(g, 200); } else { // testing if AUWLBook is undefined (AUWL is their global object for it) // If it is, they add the &lt;script&gt; tag for their JS (variable u) if (typeof AUWLBook == x) s.setAttribute('src', u + '.js?loc=' + e(l)), d.body.appendChild(s); function f() { // they keep looping through until the Object is finally created // Then they call the showPopover function which initializes everything // Builds all the HTML (with JS, etc) (typeof AUWLBook == x) ? setTimeout(f, 200) : AUWLBook.showPopover(); } f(); } } g(); }()) </code></pre> <p>As you can see an anonymous function is being created, and the jist of what is happening here is that they are creating a script element <strong>s = d.createElement('script')</strong>, into your current document which then loads the rest of the bookmarklet.</p> <pre><code>// since their global object will be undefined at first they create it if (typeof AUWLBook == x) s.setAttribute('src', u + '.js?loc=' + e(l)), d.body.appendChild(s); </code></pre> <p>As for the string building for the href... it looks like <code>l.href = u + '?u=' + e(l) + '&amp;t=' + e(d.title);</code> is for their internal reference so they know what page/etc you came from, i'm assuming they are building what the Wish list item is from the Title of the page (that's what it looks like at least).</p> <p>You can see their entire JS code here, they have a whole lot going on: <a href="https://www.amazon.co.uk/wishlist/add.js?loc=http://fiddle.jshell.net/_display/&amp;b=AUWLBookenGB" rel="nofollow">Amazong Bookmarklet JS Link</a></p> <p>But as you can see they build the entire popup &amp; the DOMelements straight from Javascript:</p> <pre><code> // (part of the AUWLBook object) showPopover : function(args){ // etc etc... // open in window if it can't create a popover if (!this.canDisplayPopover()) { window.location.href = 'https://www.amazon.co.uk/wishlist/add' + '?u=' + encodeURIComponent(window.location) + '&amp;t=' + encodeURIComponent(document.title); return; } // Then comes just an insane amount of lines of creating all the elements floater = shmCreateElement('table', { width: bookmarkletWidth, border: '0', id: 'auwlPopover' }, {position: 'absolute', zIndex: '999999999', width: bookmarkletWidth, tableLayout: 'auto', lineHeight: '100%', borderCollapse: 'collapse'}); </code></pre> <p>shmCreateElement being their internal html creation function (i'd def suggest copying it)</p> <pre><code> function shmCreateElement(tagName, props, styles, children) { ... } </code></pre> <p>So I guess basically you need to have whatever you want to appear completely coming from JS, have it injected into the current pages document DOM, and there you go.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload