Skip to content

Tutorials

NodeBB guides, how-to's and general tips and tricks

82 Topics 599 Posts
  • [script] Noembed Embed

    1
    1 Votes
    1 Posts
    1k Views
    P

    Hello, I see that you guys use magickblock plugin, maybe i'll test it later but I am sharing a script I wrote to automarically embedding noembed supported sites.

    As I don't have patience to maintain a plugin, I just put this in ACP / Appearance / Custom HTML & CSS / Custom Headers.

    <script> $(document).ready(function(){ $('head').append('<link rel="stylesheet" type="text/css" href="https://noembed.com/noembed.css">'); setProviders(); $(window).ajaxComplete(function(){ $("div.post-content > p > a:not(.embedded)").addClass("embedded").each(function(){ noembed(this.href, this.closest("div.post-content")); }); }); }); function setProviders() { //window.embedProviders = new RegExp(); providersArray = []; patternsArray = []; $.ajax({ url: "https://noembed.com/providers", type: "get", success: function(data){ providersArray = JSON.parse(data); while(providersArray.length) { patternsArray.push( providersArray.pop()['patterns'] ); } window.embedProviders = new RegExp(patternsArray.join('|'), 'i'); }, datatype: "json" }); } function testurl(url) { return function(){window.embedProviders.test(url)}; } function noembed(myhref,mydiv) { if(testurl(myhref)) { $.ajax({ url: "https://noembed.com/embed", type: "get", data: {url: myhref}, dataType: "json", success: function(data){ $(mydiv).append(data['html']); } }); } } </script>

    Noembed is an open source perl (plack) app, one can host it's own and it seems the app acts as a hub to the embed.

  • Tutorials!

    3
    8 Votes
    3 Posts
    4k Views
    Jared14406J

    @yariplus yeah. I agree with u on that and if that does get created than please move my forum tutorials to the basic tutorial section thanks!