make twitter links have "nofollow noopener norefeerrer"

remotes/1693045480750635534/spooky-22
Aevann1 2022-06-11 11:53:53 +02:00
parent 3b50c92afb
commit c0da5ed7d9
1 changed files with 3 additions and 1 deletions

View File

@ -857,7 +857,9 @@ def submit_post(v, sub=None):
reason = f"Remove the {domain_obj.domain} link from your post and try again. {domain_obj.reason}"
return error(reason)
elif "twitter.com" == domain:
try: embed = requests.get("https://publish.twitter.com/oembed", params={"url":url, "omit_script":"t"}, timeout=5).json()["html"]
try:
embed = requests.get("https://publish.twitter.com/oembed", params={"url":url, "omit_script":"t"}, timeout=5).json()["html"]
embed = embed.replace('<a href', '<a rel="nofollow noopener noreferrer" href')
except: pass
elif url.startswith('https://youtube.com/watch?v='):
url = unquote(url).replace('?t', '&t')