loon3 / Tokenly-Pockets

Digital Token Wallet powered by Bitcoin
GNU General Public License v3.0
7 stars 14 forks source link

Need to generate payment buttons on the fly #4

Closed deweller closed 9 years ago

deweller commented 9 years ago

Some applications (like Swapbot) need to generate payment buttons via javascript after the pages have loaded.

Because of this, the <span> is not picked up and handled by the extension.

Maybe we can add a listener event to the the tipbutton.js content script that listens for a request from the page to look again for any tip buttons. It might look something like this:

window.addEventListener('POCKETS_REPARSE', function(event) {
    // run the parser again...
   parseForButtons();
});
deweller commented 9 years ago

I found http://stackoverflow.com/a/14656720 for a good explanation of the technique involved here.

loon3 commented 9 years ago

Since all you need is the URL of the chrome extension and the pockets image, my solution is to store that info in hidden div's so that you can call it whenever you need. See example here, https://github.com/loon3/Tokenly-Pockets/blob/master/Chrome%20Extension/test/paymentbutton_example.js

So in this case, you'll need two hidden div's with the classes .pockets-url and .pockets-image

loon3 commented 9 years ago

Revise content script to use data attributes...

<div data-pockets-url></div> $(‘div[data-pockets-url]’).text()

loon3 commented 9 years ago

implemented https://github.com/loon3/Tokenly-Pockets/blob/master/Pockets%20Payment%20Button.md