lottidah
05-25-2020, 01:55 PM
I've been using a custom BB code to embed tweets in vBulletin. Recently, it is no longer working. We are on version 5.6.1. This code was provided by Glenn at vbmods.rocks (https://vbmods.rocks/forum/vbulletin-5-modifications/vbulletin-5-custom-bb-codes/192-tweet-bbcode) but he is AWOL these days. The HTML code in BB Manager for this is:
<div data-tweet-param="TweetUrlOrTweetIdHere"></div><script>(function(){function k(a,c){var d=Element.prototype;return(d.matches||d.webkitMatc hesSelector||d.mozMatchesSelector||d.msMatchesSele ctor||function(a){return-1!==[].indexOf.call(document.querySelectorAll(a),this)}) .call(a,c)}function g(a,c){return a?k(a,c)?a:"HTML"===a.tagName?null:g(a.parentNode,c):null}var b="TweetUrlOrTweetIdHere",a,e=document.getElementsByTagName("script"),e=e[e.length-1],f;if(/^http[s]*:\/\//.test(b)){a=document.createElement("a");a.href=b;b=a.pathname.substring(a.pathname.lastI ndexOf("/")+1)}f=e.parentNode.querySelector('[data-tweet-param="TweetUrlOrTweetIdHere"]:empty');(a=g(f,".js-post"))?a=a.getAttribute("data-node-id"):(a=g(f,".js-post-sm"),a=a?a.getAttribute("data-nodeid"):Math.floor(Math.random()*10000));a="t_"+(a||"")+"_"+b;window[a]=function(a){f.innerHTML=a.html;a=f.getElementsByT agName("script");for(var c,d=document.getElementsByTagName("head")[0],b=0;b<a.length;b++)a[b].src?(c=document.createElement("script"),c.src=a[b].src,d.appendChild(c)):eval(a[b].textContent)};var h=document.createElement("script");h.src="https://api.twitter.com/1/statuses/oembed.json?id="+b+decodeURIComponent("%26")+"callback="+a;e.parentNode.appendChild(h)})();</script>
Any ideas if the code needs updating or if there is now a better way to embed tweets into vBulletin 5.6.1?
Thanks
<div data-tweet-param="TweetUrlOrTweetIdHere"></div><script>(function(){function k(a,c){var d=Element.prototype;return(d.matches||d.webkitMatc hesSelector||d.mozMatchesSelector||d.msMatchesSele ctor||function(a){return-1!==[].indexOf.call(document.querySelectorAll(a),this)}) .call(a,c)}function g(a,c){return a?k(a,c)?a:"HTML"===a.tagName?null:g(a.parentNode,c):null}var b="TweetUrlOrTweetIdHere",a,e=document.getElementsByTagName("script"),e=e[e.length-1],f;if(/^http[s]*:\/\//.test(b)){a=document.createElement("a");a.href=b;b=a.pathname.substring(a.pathname.lastI ndexOf("/")+1)}f=e.parentNode.querySelector('[data-tweet-param="TweetUrlOrTweetIdHere"]:empty');(a=g(f,".js-post"))?a=a.getAttribute("data-node-id"):(a=g(f,".js-post-sm"),a=a?a.getAttribute("data-nodeid"):Math.floor(Math.random()*10000));a="t_"+(a||"")+"_"+b;window[a]=function(a){f.innerHTML=a.html;a=f.getElementsByT agName("script");for(var c,d=document.getElementsByTagName("head")[0],b=0;b<a.length;b++)a[b].src?(c=document.createElement("script"),c.src=a[b].src,d.appendChild(c)):eval(a[b].textContent)};var h=document.createElement("script");h.src="https://api.twitter.com/1/statuses/oembed.json?id="+b+decodeURIComponent("%26")+"callback="+a;e.parentNode.appendChild(h)})();</script>
Any ideas if the code needs updating or if there is now a better way to embed tweets into vBulletin 5.6.1?
Thanks