从嵌入式推文中删除按钮 [英] Remove follow button from embedded tweet

查看:86
本文介绍了从嵌入式推文中删除按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在网站上嵌入了推文,我想删除关注按钮以及回复最爱转推按钮那些在页脚中。一个最小的HTML例子如下

I'm embedding tweet on a website and I would like to remove the follow button and also the reply, favorite and retweet buttons that are in the footer. A minimal HTML example is the following

<blockquote class="twitter-tweet">
    <a href="https://twitter.com/StackCareers/statuses/468107750333894656"></a>
</blockquote>
<script src="http://platform.twitter.com/widgets.js" charset="utf-8"></script>

通过检查代码,一旦推文被显示出来,我认为按钮被封装为

By inspecting the code, once the tweet is diplayed, I figured that the button is wrapped as following

<a class="follow-button profile" href="https://twitter.com/StackCareers" role="button" data-scribe="component:followbutton" title="Follow StackOverflowCareers on Twitter"><i class="ic-button-bird"></i>Follow</a>

到目前为止,我试图使用JQuery去除这个类。

So far I tried to remove this class using JQuery

$('.follow-button.profile').remove()

我也尝试通过将以下行添加到我的样式表中来覆盖css:

I also tried to overwrite the css by adding the following line to my stylesheet :

.follow-button {visibility:hidden;}

并遵循 post ,我试着添加这一行

And following this post, I tried adding also this line

.twt-actions { display: none; }

以上都无效。有没有一种解决方案来定制这些嵌入式推文?

None of the above worked. Is there a solution to customize these embedded tweets ?

推荐答案

这是不可能的。您将跨域内容从具有同源策略的源代码加载到iframe中,这意味着您无法操作Javascript中的内容。

This is not possible. You are loading cross-domain content into an iframe from a source with a same-origin policy, which means you cannot manipulate the contents from your Javascript.

就我而言我知道,对于不使用iframe的推文,没有开箱即用的嵌入代码。

As far as I am aware, there is no out-of-the-box embed code for tweets that doesn't use an iframe.

您有两种选择。第一个选项是按照提供的方式显示推文。第二种选择是使用API​​检索推文并按照您的要求显示。对于后者,您必须注册一个API密钥。

You have two options. The first option is to display the tweet as it is provided. The second options is to use the API to retrieve the tweet and display it as you please. For the latter, you'll have to sign up for an API key.

或者,您可能能够找到解决方法这里,但我不能保证任何这些建议的实施质量。

Alternatively, you may be able to find a workaround here but I can't vouch for the quality of any implementation of any of these suggestions.

这篇关于从嵌入式推文中删除按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆