Last active
November 19, 2020 12:03
-
-
Save laechan/fb9cceb0645734a2a9d58b3c78b2c30e to your computer and use it in GitHub Desktop.
laechan's pageframe
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<Meta Http-Equiv="Content-Type" Content="text/html; Charset=utf-8"> | |
<body bgcolor="#93FF93"> | |
<pre id=content style='display:none'> | |
在 pre.../pre 之間放你想寫的文章 | |
網址測試 | |
https://www.ptt.cc/bbs/Japan_Travel/M.1584370429.A.62F.html | |
貼圖測試 | |
https://i.imgur.com/XNXwqxy.jpg | |
youtube 影片測試 | |
https://www.youtube.com/watch?v=bjxcx3zLdLc | |
</pre> | |
<script type="text/javascript"> | |
MEDIA_WIDTH=640; | |
MEDIA_HEIGHT=360; | |
FONT_SIZE=4; | |
content=document.getElementById("content").innerHTML; | |
tmps=content.split("\n"); | |
for(i=0;i<tmps.length;i++) | |
{ | |
tmp=tmps[i]; | |
if(tmp=="") continue; | |
if(tmp.indexOf("http")!=-1) | |
{ | |
s=tmp.indexOf("http"); | |
e=s; | |
while(e++<tmp.length) | |
if(tmp.substr(e,1)==" ") | |
break; | |
if(e==s) | |
e=tmp.length-1; | |
url=tmp.substr(s,e-s); | |
tmp="<a href='"+url+"' target=_blank>"+url+"</a>"; | |
if(url.indexOf("imgur.com")!=-1 || url.substr(-4,1)==".") | |
{ | |
if(url.substr(-4,1)!=".") url+=".jpg"; | |
tmp+="<BR><a href='"+url+"' target=_blank>"+ | |
"<img width="+MEDIA_WIDTH+" src='"+url+"'></a><BR>"; | |
} | |
else if(url.indexOf("youtu")!=-1) | |
{ | |
urls=url.split("watch?v="); | |
url=urls[0]+"embed/"+urls[1]; | |
tmp+="<BR><iframe width="+MEDIA_WIDTH+" height="+ | |
MEDIA_HEIGHT+" src='"+url+"' frameborder=0 allow='"+ | |
"accelerometer; autoplay; clipboard-write; encrypted-media; "+ | |
"gyroscope; picture-in-picture' allowfullscreen></iframe><BR>"; | |
} | |
tmps[i]=tmp; | |
} | |
} | |
content="<font size="+FONT_SIZE+">"+tmps.join("<BR>")+"</font>"; | |
document.write(content); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment