Chrome扩展程序中的Coinbase自定义按钮

时间:2014-05-31 08:58:57

标签: jquery google-chrome-extension coinbase-api

我尝试在Google Chrome扩展程序中添加自定义coinbase付款按钮。

我已经让它在jsfiddle中工作了:http://jsfiddle.net/hqhLV/

$(document).ready(function () {

code = "65a580d7449cc35869c9bd0d49cf77bd";

function get_button_html(code) {
    var button_html = "<div class='coinbase-button' data-code='65a580d7449cc35869c9bd0d49cf77bd' data-button-style='none'></div>";

    return button_html;
}

function loadButton(code) {
    $('body').after("<a href='' class='my-custom-link'>Show Me The Modal!</a>", get_button_html(code));
};

loadButton(code);
$.getScript("https://coinbase.com/assets/button.js");

$('.my-custom-link').click(function () {
    console.log('coinbase_show_modal');
    $(document).trigger('coinbase_show_modal', '65a580d7449cc35869c9bd0d49cf77bd');
    return false;
});

$(document).on('coinbase_payment_complete', function (event, code) {
    console.log("Payment completed for button " + code);
    window.location = "/confirmation.html";
});

});

但是,将代码复制为扩展名中的内容脚本文件。知道可能是什么原因吗?

0 个答案:

没有答案