I am trying to embed a reddit widget into my qualtrics survey and it is working fine, but I don't like that the widget by default doesn't show the full post and has a "read more" button (see image). It barely shows any of the post as is. Is there a way to render it without the "Read More" button?
Screenshot of the Reddit widget
Below is my Qualtrics code:
HTML:
<div id="embeddedPost3">
<blockquote class="reddit-embed-bq" data-embed-height="316" id="redditBlockquote3" style="height:316px">
<a href="" id="redditLink3"></a>
</blockquote>
</div>
Javascript:
Qualtrics.SurveyEngine.addOnReady(function() {
var url_1c = "https://www.reddit.com/r/webdev/comments/134ldxr/recommended_way_to_embed_reddit_posts/"
var platform_1 = "reddit"
// Set the href attribute of the blockquote anchor tag
if (platform_1 == "reddit") {
const redditLink3 = document.getElementById('redditLink3');
redditLink3.href = url_1c;
let s = document.createElement("script");
s.src = "https://embed.reddit.com/widgets.js"
document.body.appendChild(s);
}
});
ChatGPT mentioned I can simulate a click on the "read more" button after it renders, but is there any better way? I'm just a bit worried about how stable that is as a solution depending on how the screen loads.
1 Answer 1
This kind of thing is tricky. You are pretty much limited to the implementation of such a widget by the provider. Looking at the customisation options when creating a post widget there seems to be no option for what you want.
Simulating a click is hard, as you cannot access the html within the <iframe />. Only by hardcoding the position of the 'Read More' button would do the trick, but that is prone to errors if Reddit decides to change the layout of the widget.
Lastly, you could use the Reddit API to fetch the contents and put them in some layout yourself. That is the option with the most control, but it will be a lot more work.
TL;DR: depending on how much work and error proneness you want to put into this, choose either of the two approaches above. There is no simple one-click solution how-ever.