如何编写嵌入clyp.it小部件的用户脚本

时间:2017-04-07 21:17:15

标签: javascript html google-chrome userscripts tampermonkey

我想录制音频并在不离开网站的情况下分享。代码适用于https://news.ycombinator.com/,如下所示:http://prntscr.com/etyzgz

但它在我想要的网站上不起作用:www.zhihu.com 按钮位于页面底部,单击后小部件不会加载。

以下是代码:

    (function() {
    'use strict';

    // Your code here...

    /*--- Create a button in a container div.  It will be styled and
    positioned with CSS.
*/ 
var zNode       = document.createElement ('div');
zNode.setAttribute ('id', 'myContainer');
zNode.style.position = 'fixed';
zNode.style.top = 50;
zNode.style.right = 50;
zNode.innerHTML = '<button id="myButton" type="button">use clyp to send voice message</button>';
document.body.appendChild(zNode);

//--- Activate the newly added button.
document.getElementById ("myButton").addEventListener('click',function(){

    var iframe       = document.createElement ('iframe');
    iframe.src = "https://clyp.it/recording-widget";
    iframe.style.width = 400;
    iframe.style.height = 400;
    document.getElementById ("myContainer").appendChild (iframe);
});


})();

0 个答案:

没有答案