MagicMirror² v2.14.0 is available! For more information about this release, check out this topic.

Random text fetch from Reddit

  • Hello everyone.
    I’m trying to display random text from random subreddits on my mirror. I have found a code that uses jQuery to fetch 10 titles from a page and that can be used successfully inside a html page.
    Link to the function ->

    The problem comes when I try to integrate that inside my module. So I try to fetch that data inside my function but using $ I don’t think it does the job. I have no idea how to call a jQuery function inside my script since the example uses a html page. I tried with the getScripts function but the result is the same.
    My code right now looks like this

    	randomQuote: function() {
    		var script = document.createElement('script');
    		script.src = '';
    		script.type = 'text/javascript';
    		var a=[];
            function foo(data)
      , 10),
                function (i, post) {
          return a;

    Any help would be much appreciated since I’m a noob with JavaScript, I’m just starting out.

Log in to reply