forked from MarseyWorld/MarseyWorld
make reddit embeds work on new.reddit.com, sh.reddit.com, reddit.com
parent
8d90b7dadd
commit
f9669e94d8
|
@ -1,11 +1,15 @@
|
|||
function embed_reddit() {
|
||||
if (navigator.doNotTrack == "1") return
|
||||
|
||||
for (const a of document.querySelectorAll('a[href^="https://old.reddit.com/r/"]:not(a[href$="/new"])')) {
|
||||
const reddit = document.getElementById('reddit').value
|
||||
|
||||
if (reddit == "undelete.pullpush.io") return
|
||||
|
||||
for (const a of document.querySelectorAll(`a[href^="https://${reddit}/r/"]:not(a[href$="/new"])`)) {
|
||||
if (a.innerHTML && a.innerHTML !== a.href) continue
|
||||
if (["STRONG", "LI", "BLOCKQUOTE", "PRE", "CODEBLOCK"].includes(a.parentElement.tagName)) continue
|
||||
|
||||
let iframe_src = a.href.replace('https://old.reddit.com/', 'https://embed.reddit.com/')
|
||||
let iframe_src = a.href.replace(`https://${reddit}/`, 'https://embed.reddit.com/')
|
||||
iframe_src = iframe_src.split('?')[0]
|
||||
iframe_src += "?context=1&showtitle=true"
|
||||
if (document.body.dataset.dark)
|
||||
|
|
|
@ -121,5 +121,6 @@
|
|||
<script defer src="{{'js/chat.js' | asset}}"></script>
|
||||
{% endif %}
|
||||
<script defer src="{{'js/vendor/twitter.js' | asset}}"></script>
|
||||
<input id="reddit" hidden value="{{v.reddit}}">
|
||||
<script defer src="{{'js/reddit_embed.js' | asset}}"></script>
|
||||
{% endblock %}
|
||||
|
|
|
@ -857,6 +857,7 @@
|
|||
{% endif %}
|
||||
|
||||
<script defer src="{{'js/vendor/twitter.js' | asset}}"></script>
|
||||
<input id="reddit" hidden value="{{v.reddit if v else 'old.reddit.com'}}">
|
||||
<script defer src="{{'js/reddit_embed.js' | asset}}"></script>
|
||||
|
||||
</body>
|
||||
|
|
|
@ -133,5 +133,6 @@
|
|||
<script defer src="{{'js/chat.js' | asset}}"></script>
|
||||
{% endif %}
|
||||
<script defer src="{{'js/vendor/twitter.js' | asset}}"></script>
|
||||
<input id="reddit" hidden value="{{v.reddit}}">
|
||||
<script defer src="{{'js/reddit_embed.js' | asset}}"></script>
|
||||
{% endblock %}
|
||||
|
|
Loading…
Reference in New Issue