forked from MarseyWorld/MarseyWorld
combine 2 functions
parent
a5e1c7d1a6
commit
af72be2037
|
@ -168,8 +168,7 @@ socket.on('speak', function(json) {
|
||||||
if (scrolled_down_var)
|
if (scrolled_down_var)
|
||||||
box.scrollTo(0, box.scrollHeight)
|
box.scrollTo(0, box.scrollHeight)
|
||||||
|
|
||||||
embed_twitter()
|
embed_twitter_reddit()
|
||||||
embed_reddit()
|
|
||||||
})
|
})
|
||||||
|
|
||||||
socket.on('error', function(message) {
|
socket.on('error', function(message) {
|
||||||
|
|
|
@ -199,8 +199,7 @@ function post_reply(id) {
|
||||||
remove_dialog();
|
remove_dialog();
|
||||||
restore_reply_buttons(`c_${id}`)
|
restore_reply_buttons(`c_${id}`)
|
||||||
|
|
||||||
embed_twitter()
|
embed_twitter_reddit()
|
||||||
embed_reddit()
|
|
||||||
} else {
|
} else {
|
||||||
showToast(false, getMessageFromJsonData(false, data));
|
showToast(false, getMessageFromJsonData(false, data));
|
||||||
}
|
}
|
||||||
|
@ -270,8 +269,7 @@ function comment_edit(id) {
|
||||||
|
|
||||||
remove_dialog();
|
remove_dialog();
|
||||||
|
|
||||||
embed_twitter()
|
embed_twitter_reddit()
|
||||||
embed_reddit()
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
showToast(false, getMessageFromJsonData(false, data));
|
showToast(false, getMessageFromJsonData(false, data));
|
||||||
|
@ -377,8 +375,7 @@ function post_comment(fullname, hide) {
|
||||||
viewbtn.dataset.ids = viewbtn.dataset.ids.slice(0, -1) + `, ${data['id']}]`
|
viewbtn.dataset.ids = viewbtn.dataset.ids.slice(0, -1) + `, ${data['id']}]`
|
||||||
}
|
}
|
||||||
|
|
||||||
embed_twitter()
|
embed_twitter_reddit()
|
||||||
embed_reddit()
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
showToast(false, getMessageFromJsonData(false, data));
|
showToast(false, getMessageFromJsonData(false, data));
|
||||||
|
|
|
@ -1,12 +1,21 @@
|
||||||
function embed_reddit() {
|
function embed_twitter_reddit() {
|
||||||
if (navigator.doNotTrack == "1") return
|
if (navigator.doNotTrack == "1") return
|
||||||
|
|
||||||
if (document.getElementById('orgy-top-container')) return
|
if (document.getElementById('orgy-top-container')) return
|
||||||
|
|
||||||
|
//twitter
|
||||||
|
for (const blockquote of document.querySelectorAll('blockquote.twitter-tweet')) {
|
||||||
|
const id = blockquote.lastChild.href.split('/status/')[1].split('?ref_src')[0]
|
||||||
|
let iframe_src = `https://platform.twitter.com/embed/Tweet.html?dnt=true&hideThread=true&id=${id}`
|
||||||
|
if (document.body.dataset.dark)
|
||||||
|
iframe_src += "&theme=dark"
|
||||||
|
|
||||||
|
blockquote.outerHTML = `<iframe class="twitter-embed" credentialless="true" allowfullscreen="true" height="240" src="${iframe_src}" scrolling="no" sandbox="allow-scripts allow-same-origin allow-popups"></iframe>`
|
||||||
|
}
|
||||||
|
|
||||||
|
//reddit
|
||||||
const reddit = document.getElementById('reddit').value
|
const reddit = document.getElementById('reddit').value
|
||||||
|
|
||||||
if (reddit == "undelete.pullpush.io") return
|
if (reddit == "undelete.pullpush.io") return
|
||||||
|
|
||||||
for (const a of document.querySelectorAll(`a[href^="https://${reddit}/r/"]:not(a[href$="/new"]), a[href^="https://${reddit}/user/"][href*="/comments/"]`)) {
|
for (const a of document.querySelectorAll(`a[href^="https://${reddit}/r/"]:not(a[href$="/new"]), a[href^="https://${reddit}/user/"][href*="/comments/"]`)) {
|
||||||
if (a.innerHTML && a.innerHTML !== a.href) continue
|
if (a.innerHTML && a.innerHTML !== a.href) continue
|
||||||
if (["STRONG", "LI", "BLOCKQUOTE", "PRE", "CODEBLOCK"].includes(a.parentElement.tagName)) continue
|
if (["STRONG", "LI", "BLOCKQUOTE", "PRE", "CODEBLOCK"].includes(a.parentElement.tagName)) continue
|
||||||
|
@ -19,10 +28,21 @@ function embed_reddit() {
|
||||||
a.outerHTML = `<iframe class="reddit-embed" credentialless="true" height="240" src="${iframe_src}" scrolling="no" sandbox="allow-scripts allow-popups allow-popups-to-escape-sandbox"></iframe>`
|
a.outerHTML = `<iframe class="reddit-embed" credentialless="true" height="240" src="${iframe_src}" scrolling="no" sandbox="allow-scripts allow-popups allow-popups-to-escape-sandbox"></iframe>`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
embed_reddit()
|
embed_twitter_reddit()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
addEventListener("message", function(e) {
|
addEventListener("message", function(e) {
|
||||||
if (typeof e.data == "string" && e.data) {
|
if (e.origin == "https://platform.twitter.com") {
|
||||||
|
const height = e.data["twttr.embed"]["params"][0]["height"]
|
||||||
|
if (height) {
|
||||||
|
for (const iframe of document.getElementsByClassName("twitter-embed")) {
|
||||||
|
if (e.source === iframe.contentWindow)
|
||||||
|
iframe.height = height
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
elif (typeof e.data == "string" && e.data) {
|
||||||
const data = JSON.parse(e.data)
|
const data = JSON.parse(e.data)
|
||||||
let height = data.data
|
let height = data.data
|
||||||
if (data && "type" in data && data.type == "resize.embed")
|
if (data && "type" in data && data.type == "resize.embed")
|
|
@ -17,8 +17,7 @@ function more_comments(cid, sort) {
|
||||||
|
|
||||||
highlight_unread("old-comment-counts")
|
highlight_unread("old-comment-counts")
|
||||||
|
|
||||||
embed_twitter()
|
embed_twitter_reddit()
|
||||||
embed_reddit()
|
|
||||||
}
|
}
|
||||||
btn.disabled = false;
|
btn.disabled = false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,27 +0,0 @@
|
||||||
function embed_twitter() {
|
|
||||||
if (navigator.doNotTrack == "1") return
|
|
||||||
|
|
||||||
if (document.getElementById('orgy-top-container')) return
|
|
||||||
|
|
||||||
for (const blockquote of document.querySelectorAll('blockquote.twitter-tweet')) {
|
|
||||||
const id = blockquote.lastChild.href.split('/status/')[1].split('?ref_src')[0]
|
|
||||||
let iframe_src = `https://platform.twitter.com/embed/Tweet.html?dnt=true&hideThread=true&id=${id}`
|
|
||||||
if (document.body.dataset.dark)
|
|
||||||
iframe_src += "&theme=dark"
|
|
||||||
|
|
||||||
blockquote.outerHTML = `<iframe class="twitter-embed" credentialless="true" allowfullscreen="true" height="240" src="${iframe_src}" scrolling="no" sandbox="allow-scripts allow-same-origin allow-popups"></iframe>`
|
|
||||||
}
|
|
||||||
}
|
|
||||||
embed_twitter()
|
|
||||||
|
|
||||||
addEventListener("message", function(e) {
|
|
||||||
if (e.origin == "https://platform.twitter.com") {
|
|
||||||
const height = e.data["twttr.embed"]["params"][0]["height"]
|
|
||||||
if (height) {
|
|
||||||
for (const iframe of document.getElementsByClassName("twitter-embed")) {
|
|
||||||
if (e.source === iframe.contentWindow)
|
|
||||||
iframe.height = height
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
|
@ -16,8 +16,7 @@ function view_more(t, pid, sort, offset) {
|
||||||
|
|
||||||
highlight_unread("old-comment-counts")
|
highlight_unread("old-comment-counts")
|
||||||
|
|
||||||
embed_twitter()
|
embed_twitter_reddit()
|
||||||
embed_reddit()
|
|
||||||
}
|
}
|
||||||
btn.disabled = false;
|
btn.disabled = false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -120,8 +120,7 @@
|
||||||
{% if not session.get("GLOBAL") %}
|
{% if not session.get("GLOBAL") %}
|
||||||
<script defer src="{{'js/chat.js' | asset}}"></script>
|
<script defer src="{{'js/chat.js' | asset}}"></script>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<script defer src="{{'js/vendor/twitter.js' | asset}}"></script>
|
|
||||||
<input id="reddit" hidden value="{{v.reddit}}">
|
<input id="reddit" hidden value="{{v.reddit}}">
|
||||||
<input id="chat_id" hidden value="{{chat_id}}">
|
<input id="chat_id" hidden value="{{chat_id}}">
|
||||||
<script defer src="{{'js/reddit_embed.js' | asset}}"></script>
|
<script defer src="{{'js/embed_twitter_reddit.js' | asset}}"></script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -865,8 +865,7 @@
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<script defer src="{{'js/vendor/twitter.js' | asset}}"></script>
|
|
||||||
<input id="reddit" hidden value="{{v.reddit if v else 'old.reddit.com'}}">
|
<input id="reddit" hidden value="{{v.reddit if v else 'old.reddit.com'}}">
|
||||||
<script defer src="{{'js/reddit_embed.js' | asset}}"></script>
|
<script defer src="{{'js/embed_twitter_reddit.js' | asset}}"></script>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|
|
@ -132,8 +132,7 @@
|
||||||
{% if not session.get("GLOBAL") %}
|
{% if not session.get("GLOBAL") %}
|
||||||
<script defer src="{{'js/chat.js' | asset}}"></script>
|
<script defer src="{{'js/chat.js' | asset}}"></script>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<script defer src="{{'js/vendor/twitter.js' | asset}}"></script>
|
|
||||||
<input id="reddit" hidden value="{{v.reddit}}">
|
<input id="reddit" hidden value="{{v.reddit}}">
|
||||||
<input id="chat_id" hidden value="{{chat_id}}">
|
<input id="chat_id" hidden value="{{chat_id}}">
|
||||||
<script defer src="{{'js/reddit_embed.js' | asset}}"></script>
|
<script defer src="{{'js/embed_twitter_reddit.js' | asset}}"></script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
Loading…
Reference in New Issue