2014-06-20 27 views
0

我需要使用隐藏的Twitter卡上的后续按钮:隐藏关注Twitter的按钮卡大段引用

<blockquote width="581" height="250" class="twitter-tweet"><p></p><a href="https://twitter.com/twitterapi/status/'+tt[i][1]+'" data-datetime="2011-11-07T20:21:07+00:00"></a></blockquote></div> 

你怎么隐藏在卡上后续的按钮?

感谢

回答

0

Twitter的插件扩展到iframe,所以你将不得不等待,直到它完全加载。之后,您可以完全删除按钮或隐藏它。你将需要一个小小的JavaScript。问题是你必须等到它被加载。我不知道如何在鸣叫完全加载时捕捉到,因此我将每隔100毫秒检查一次按钮,直到它出现。你当然可以改变它以适应你的需求。

JS:

window.setTimeout(removeButton, 100); 

function removeButton() { 
    var iframe = document.querySelector('iframe.twitter-tweet'); 
    if(iframe == undefined) { 
     window.setTimeout(removeButton, 100); 
     return; 
    } 
    var button = iframe.contentDocument.querySelector('.follow-button.profile'); 
    if(button == undefined) { 
     window.setTimeout(removeButton, 100); 
     return; 
    } 

    //Hide 
    button.style.display = 'none'; 

    //Or remove 
    button.parentNode.removeChild(button); //Note: Not using button.remove() because of compatibility 
} 

这当然目前仅适用于一个单一的鸣叫。如果您想删除多个Follow按钮,则必须稍微修改此脚本。