AddThis插件无法排除手机工具箱中的服务

AddThis plugin can not exclude services in mobile tool box

我在 their instructions 之后实现了 addThis 分享框。我只想在分享工具箱中包含以下服务,这些服务在桌面浏览器上运行良好,但在移动设备上会被忽略,这意味着每项服务都会显示在移动版的分享箱中。

还有其他人遇到过这个问题吗?可以做些什么来修复它?

<script src="https://s7.addthis.com/js/300/addthis_widget.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<div class="share_btn">Press me to test sharing!!!!</div>
<script>
var addthis_config = { 
    services_expanded: 'facebook,twitter,email,tumblr,link,sinaweibo,whatsapp'
}

$(".share_btn").on("click", function () {
    addthis.update('share', 'url', 'http://google.com');
    addthis_sendto('more');
});
</script>

JSFiddle - Test link

在移动浏览器上,您应该使用 TouchEvents

尝试在此处添加 touchstart

$(".sharing").on("click touchstart", function () {
    ...
});

是在每部手机中还是只是 iOS?如果只在 ios 上试试这个:

$(document).ready(function() {
  var $ua = navigator.userAgent;
  var $event = ($ua.match(/(iPod|iPhone|iPad)/i)) ? "touchstart" : "click";

  $(document).on($event, function(ev) {
    addthis.update('share', 'url', 'http://google.com');
    addthis_sendto('more');
  });
});

这是一个错误

您正确地应用了配置问题是这是一个已经存在了几年的错误:

2013 年 6 月有用户回复:

We have an addthis control that properly displays only the sharing services that we specify when viewed using a desktop browser. When it is viewed from a mobile device (iphone in this case) it switches to the mobile view i na new tab (which is good), but then it displays every possible service instead of just the specific ones that we want to show. Is there some additional configuration we need to do up front in addition to what we are already doing?

AddThis 团队成员回复:

I tested this on a local environment and experienced the same result. I have put in a ticket with our development team for a fix in a future release. Thank you for reporting this to us.

AddThis 支持 (Addthis mobile not respecting 'services_compact' or 'services_expanded')

This was still outstanding when another user asked if it had been fixed a year later.

你能做什么?

您唯一的选择似乎是使用 services_exclude,这似乎在移动设备上有效。这将导致 lot 更长的列表和更多的配置问题,但它应该允许您 almost 获得您想要的列表移动菜单。

<script src="https://s7.addthis.com/js/300/addthis_widget.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<div class="share_btn">Press me to test sharing!!!!</div>
<script>
  var addthis_config = {
    services_exclude: 'dashboard,menu,compact,email,facebook_like,foursquare,google_plusone,pinterest,100zakladok,a97abi,addressbar,adfty,adifni,advqr,amazonwishlist,amenme,aim,aolmail,apsense,arto,baang,baidu,balatarin,balltribe,beat100,biggerpockets,bitly,bizsugar,bland,blogger,blogkeen,blogmarks,blurpalicious,bobrdobr,bonzobox,socialbookmarkingnet,bookmarkycz,bookmerkende,box,brainify,bryderi,buddymarks,buffer,camyoo,care2,foodlve,chiq,citeulike,classicalplace,google_classroom,cleanprint,cleansave,cndig,colivia,technerd,link,cosmiq,cssbased,delicious,diary_ru,digaculturanet,digg,diggita,digo,diigo,domelhor,douban,draugiem,dzone,edcast,efactor,mailto,embarkons,evernote,stylishhome,fabulously40,informazione,thefancy,fashiolista,favable,faves,favlogde,favoritende,favorites,favoritus,financialjuice,flipboard,folkd,thefreedictionary,fresqui,funp,gg,gmail,govn,goodnoows,google,googleplus,googletranslate,google_plusone_share,hackernews,hatena,gluvsnap,hedgehogs,historious,hootsuite,hotmail,w3validator,identica,ihavegot,indexor,instapaper,iorbix,irepeater,jamespot,jappy,jolly,kaevur,kaixin,kakao,ketnooi,kik,kindleit,kledy,latafaneracat,librerio,lidar,lineme,linkedin,linkuj,livejournal,mymailru,margarin,markme,meinvz,memonic,memori,mendeley,meneame,mixi,moemesto,moikrug,mrcnetworkit,myspace,myvidster,n4g,naszaklasa,netlog,netvibes,netvouz,newsmeback,newsvine,nujij,nurses_lounge,odnoklassniki_ru,oknotizie,openthedoor,oyyla,packg,pafnetde,pdfonline,pdfmyurl,phonefavs,pinboard,pinterest_share,planypus,plaxo,plurk,pocket,posteezy,print,printfriendly,pusha,qrsrc,quantcast,qzone,reddit,rediff,redkum,renren,researchgate,safelinking,scoopat,scoopit,sekoman,select2gether,shaveh,shetoldme,skype,skyrock,slack,smiru,sodahead,sonico,spinsnap,yiid,startaid,startlap,studivz,stuffpit,stumbleupon,stumpedia,sulia,sunlize,supbro,surfingbird,svejo,symbaloo,taringa,telegram,tencentweibo,thewebblend,thisnext,tuenti,tulinq,twitthis,typepad,urlaubswerkde,viadeo,viber,virb,visitezmonsite,vk,vkrugudruzei,voxopolis,vybralisme,wanelo,internetarchive,sharer,webnews,domaintoolswhois,windows,wirefan,wishmindr,wordpress,raiseyourvoice,wykop,xanga,xing,yahoomail,yammer,yardbarker,yigg,yookos,yoolink,yorumcuyum,youmob,yummly,yuuby,zakladoknet,ziczac,zingme'
  }

  $(".share_btn").on("click", function() {
    addthis.update('share', 'url', 'http://google.com');
    addthis_sendto('more');
  });
</script>

Stack Snippet 似乎无法正常工作,因此要查看实际效果,请参阅此 JSFiddle

不幸的是,使用此方法会突出显示另一个错误,该错误会导致 Facebook、Twitter 和 Tumbler 按钮重复(如上所示)。似乎没有办法配置 AddThis 来停止这种复制,但是,可以从不同的角度解决这个问题。

移动菜单被赋予了唯一性 类(以区别于桌面菜单)并且重复项始终显示为前三个项目。这意味着我们可以使用 CSS 来隐藏前三个列表项,并通过扩展从视图中删除重复项。

.at4m-listitem:nth-child(-n+3) {
  display: none;
}
<script src="https://s7.addthis.com/js/300/addthis_widget.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<div class="share_btn">Press me to test sharing!!!!</div>
<script>
  var addthis_config = {
    services_exclude: 'dashboard,menu,compact,email,facebook_like,foursquare,google_plusone,pinterest,100zakladok,a97abi,addressbar,adfty,adifni,advqr,amazonwishlist,amenme,aim,aolmail,apsense,arto,baang,baidu,balatarin,balltribe,beat100,biggerpockets,bitly,bizsugar,bland,blogger,blogkeen,blogmarks,blurpalicious,bobrdobr,bonzobox,socialbookmarkingnet,bookmarkycz,bookmerkende,box,brainify,bryderi,buddymarks,buffer,camyoo,care2,foodlve,chiq,citeulike,classicalplace,google_classroom,cleanprint,cleansave,cndig,colivia,technerd,link,cosmiq,cssbased,delicious,diary_ru,digaculturanet,digg,diggita,digo,diigo,domelhor,douban,draugiem,dzone,edcast,efactor,mailto,embarkons,evernote,stylishhome,fabulously40,informazione,thefancy,fashiolista,favable,faves,favlogde,favoritende,favorites,favoritus,financialjuice,flipboard,folkd,thefreedictionary,fresqui,funp,gg,gmail,govn,goodnoows,google,googleplus,googletranslate,google_plusone_share,hackernews,hatena,gluvsnap,hedgehogs,historious,hootsuite,hotmail,w3validator,identica,ihavegot,indexor,instapaper,iorbix,irepeater,jamespot,jappy,jolly,kaevur,kaixin,kakao,ketnooi,kik,kindleit,kledy,latafaneracat,librerio,lidar,lineme,linkedin,linkuj,livejournal,mymailru,margarin,markme,meinvz,memonic,memori,mendeley,meneame,mixi,moemesto,moikrug,mrcnetworkit,myspace,myvidster,n4g,naszaklasa,netlog,netvibes,netvouz,newsmeback,newsvine,nujij,nurses_lounge,odnoklassniki_ru,oknotizie,openthedoor,oyyla,packg,pafnetde,pdfonline,pdfmyurl,phonefavs,pinboard,pinterest_share,planypus,plaxo,plurk,pocket,posteezy,print,printfriendly,pusha,qrsrc,quantcast,qzone,reddit,rediff,redkum,renren,researchgate,safelinking,scoopat,scoopit,sekoman,select2gether,shaveh,shetoldme,skype,skyrock,slack,smiru,sodahead,sonico,spinsnap,yiid,startaid,startlap,studivz,stuffpit,stumbleupon,stumpedia,sulia,sunlize,supbro,surfingbird,svejo,symbaloo,taringa,telegram,tencentweibo,thewebblend,thisnext,tuenti,tulinq,twitthis,typepad,urlaubswerkde,viadeo,viber,virb,visitezmonsite,vk,vkrugudruzei,voxopolis,vybralisme,wanelo,internetarchive,sharer,webnews,domaintoolswhois,windows,wirefan,wishmindr,wordpress,raiseyourvoice,wykop,xanga,xing,yahoomail,yammer,yardbarker,yigg,yookos,yoolink,yorumcuyum,youmob,yummly,yuuby,zakladoknet,ziczac,zingme'
  }

  $(".share_btn").on("click", function() {
    addthis.update('share', 'url', 'http://google.com');
    addthis_sendto('more');
  });
</script>

Stack Snippet 似乎无法正常工作,因此要查看实际效果,请参阅此 JSFiddle

好问题!不幸的是,AddThis 是一项 fly-by-night 操作,他们已停止作为一项 social-sharing 服务进行操作。如果您现在访问他们的网站并查看主页,您会发现他们现在是一家开发公司,出售社交分享网站的链接列表。

事实上,如果您现在访问 addthis.com 网站,您将在该网站上看到以下标题:

Free Website Tools

此外:

AddThis is known for our beautifully simple share buttons.

这很有趣。一个曾经是社交网络的站点,但现在正在为其他社交网络销售服务。更不幸的是,他们所有的演示似乎都是空白的,lorem-ipsum html 页。

我不会说这是目前要实施的可靠服务!

我维护一个社交分享 URLs GitHub 项目!我们 USED 来实现 AddThis,但我们的测试套件发现了这个错误,我们已将其从我们的项目中删除。想要确定性和可靠性以及您的社交分享?然后检查我们! GitHub: Social Share URLs.