Removed tracking/stats, anything non-embed related
This commit is contained in:
parent
7a0b2660c5
commit
87ba86ba50
8 changed files with 14 additions and 1131 deletions
Binary file not shown.
|
@ -1,4 +0,0 @@
|
|||
body {
|
||||
margin-right: 40%;
|
||||
background: color 0;
|
||||
}
|
288
static/main.js
288
static/main.js
|
@ -1,288 +0,0 @@
|
|||
var tweetCount = 1,
|
||||
page = 0,
|
||||
loading = false,
|
||||
bigArray = [],
|
||||
isNSFWSHOW = false;
|
||||
const iosHeight = () => {
|
||||
document.documentElement.style.setProperty("--ios-height", window.innerHeight + "px");
|
||||
};
|
||||
window.addEventListener("resize", iosHeight);
|
||||
|
||||
window.onload = () => {
|
||||
//ios height
|
||||
iosHeight();
|
||||
const contwarn = document.querySelector("#contwarn");
|
||||
const notsafe = document.querySelector("#notsafe");
|
||||
if (document.cookie.includes("NSFW=true")) {
|
||||
notsafe.checked = true;
|
||||
isNSFWSHOW = true;
|
||||
}
|
||||
if (document.cookie.includes("always=true")) {
|
||||
contwarn.checked = true;
|
||||
forNow();
|
||||
}
|
||||
contwarn.addEventListener("change", () => {
|
||||
if (contwarn.checked)
|
||||
addCookie("always", true);
|
||||
else
|
||||
addCookie("always", false);
|
||||
})
|
||||
notsafe.addEventListener("change", () => {
|
||||
if (notsafe.checked) {
|
||||
document.querySelectorAll(".nsfw").forEach(e => e.classList.add("noff"));
|
||||
addCookie("NSFW", true);
|
||||
isNSFWSHOW = true;
|
||||
}
|
||||
else {
|
||||
document.querySelectorAll(".noff").forEach(e => e.classList.remove("noff"));
|
||||
isNSFWSHOW = false;
|
||||
addCookie("NSFW", false);
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
function addCookie(name, state) {
|
||||
if (state)
|
||||
document.cookie = `${name}=${state}; max-age=15780000; SameSite=None; Secure`;
|
||||
else
|
||||
document.cookie = `${name}=`;
|
||||
}
|
||||
|
||||
function cookieTime() {
|
||||
document.querySelector("#contwarn").checked = true;
|
||||
addCookie("always", true);
|
||||
forNow();
|
||||
}
|
||||
function forNow() {
|
||||
document.querySelector("#block").style.display = "none";
|
||||
fetchNApply(page)
|
||||
page++;
|
||||
const tweetCont = document.querySelector(".tweetCont");
|
||||
tweetCont.onscroll = async () => {
|
||||
if (tweetCont.scrollTop > tweetCont.scrollHeight - tweetCont.offsetHeight - 100 && loading == false) {
|
||||
await fetchNApply(page);
|
||||
//console.log(page);
|
||||
page++;
|
||||
}
|
||||
};
|
||||
}
|
||||
function fetchNApply(page) {
|
||||
try {
|
||||
loading = true;
|
||||
fetch(`https://fxtwitter.com/api/latest/?tweets=10&page=${page}`)
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
data.forEach(e => createTweet(e));
|
||||
})
|
||||
.then(setTimeout(() => loading = false, 500));
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
alert(error)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function imgPrev(img) {
|
||||
const prevImgCont = document.querySelector('.previmgcont');
|
||||
img.addEventListener('click', () => {
|
||||
const clone = img.cloneNode(true);
|
||||
clone.removeAttribute("width");
|
||||
clone.removeAttribute("height");
|
||||
clone.className = "previmg";
|
||||
prevImgCont.innerHTML = "";
|
||||
prevImgCont.appendChild(clone);
|
||||
prevImgCont.style.display = '';
|
||||
});
|
||||
}
|
||||
/*
|
||||
cont ={
|
||||
inner: text
|
||||
src: link
|
||||
lazy: bool
|
||||
href: link
|
||||
video: link
|
||||
}
|
||||
*/
|
||||
function createEl(tag, cls, cont) {
|
||||
const el = document.createElement(tag);
|
||||
if (cls)
|
||||
el.className = cls;
|
||||
if (cont) {
|
||||
if (cont.inner)
|
||||
el.innerHTML = cont.inner;
|
||||
if (cont.src)
|
||||
el.src = cont.src;
|
||||
if (cont.lazy)
|
||||
el.setAttribute("loading", "lazy");
|
||||
if (cont.href)
|
||||
el.setAttribute("href", cont.href),
|
||||
el.setAttribute("rel", "noreferrer"),
|
||||
el.setAttribute("target", "_blank");
|
||||
if (cont.video) {
|
||||
el.setAttribute("preload", "auto");
|
||||
el.setAttribute("controls", "");
|
||||
el.setAttribute("disablePictureInPicture", "");
|
||||
el.setAttribute("webkit-playsinline", "");
|
||||
el.setAttribute("playsinline", "");
|
||||
const source = document.createElement("source");
|
||||
source.src = cont.video;
|
||||
source.setAttribute("type", "video/mp4");
|
||||
el.appendChild(source);
|
||||
}
|
||||
}
|
||||
return el;
|
||||
}
|
||||
|
||||
function createTweet(json) {
|
||||
if (!bigArray.includes(json["tweet"])) {
|
||||
const tweet = createEl("div", "tweet");
|
||||
tweet.id = "t" + tweetCount;
|
||||
|
||||
const auth = createEl("div", "auth");
|
||||
|
||||
const aimage = createEl("img", "aimage", {
|
||||
src: json["pfp"],
|
||||
lazy: true
|
||||
});
|
||||
|
||||
const aname = createEl("a", "aname", {
|
||||
href: `https://twitter.com/${json['screen_name']}`
|
||||
});
|
||||
|
||||
aname.appendChild(createEl("div", undefined, {
|
||||
inner: json['uploader']
|
||||
}));
|
||||
|
||||
aname.appendChild(createEl("div", undefined, {
|
||||
inner: "@" + json['screen_name']
|
||||
}));
|
||||
|
||||
const type = createEl("a", "type", { inner: json["type"], href: json["tweet"] });
|
||||
|
||||
auth.appendChild(aimage);
|
||||
auth.appendChild(aname);
|
||||
auth.appendChild(type);
|
||||
|
||||
tweet.appendChild(auth);
|
||||
|
||||
json["description"] = json["description"].replaceAll(/http.*t.co\S+/g, "");
|
||||
|
||||
|
||||
if (json["description"] != "") {
|
||||
const desc = createEl("div", "desc", { inner: json["description"] });
|
||||
tweet.appendChild(desc);
|
||||
}
|
||||
|
||||
if (json["nsfw"]) { //beware
|
||||
var nsfw = createEl("div", "nsfw");
|
||||
const ncont = createEl("div", "ncont");
|
||||
const ninfo = createEl("div", "ninfo", { inner: "This is a NSFW Tweet <br> Press \"Show me\" if you want to see it" });
|
||||
var nshow = createEl("div", "nshow", { inner: "Show me" });
|
||||
ncont.appendChild(ninfo);
|
||||
ncont.appendChild(nshow);
|
||||
nsfw.appendChild(ncont);
|
||||
if (isNSFWSHOW === true)
|
||||
nsfw.classList.add("noff");
|
||||
}
|
||||
|
||||
|
||||
switch (json["type"]) {
|
||||
case "Text":
|
||||
//so empty
|
||||
break;
|
||||
case "Image":
|
||||
if (json["images"][4] > "1" && json["images"][4]) { //multiple images!!??
|
||||
const grid = createEl("div", "imgCont");
|
||||
for (let i = 0; i < json["images"][4]; i++)
|
||||
grid.appendChild(createEl("img", "media", {
|
||||
src: json["images"][i],
|
||||
lazy: true
|
||||
}));
|
||||
//console.log(json["images"][4])
|
||||
if (nsfw)
|
||||
nsfw.appendChild(grid);
|
||||
else
|
||||
tweet.appendChild(grid);
|
||||
}
|
||||
else {
|
||||
const media = createEl("img", "media", {
|
||||
src: json["thumbnail"],
|
||||
lazy: true
|
||||
});
|
||||
if (nsfw)
|
||||
nsfw.appendChild(media);
|
||||
else
|
||||
tweet.appendChild(media);
|
||||
}
|
||||
|
||||
break;
|
||||
case "Video":
|
||||
const video = createEl("video", "media", {
|
||||
video: json["url"]
|
||||
});
|
||||
if (nsfw)
|
||||
nsfw.appendChild(video);
|
||||
else
|
||||
tweet.appendChild(video);
|
||||
break;
|
||||
default:
|
||||
const video2 = createEl("video", "media", {
|
||||
video: json["url"]
|
||||
});
|
||||
if (nsfw)
|
||||
nsfw.appendChild(video2);
|
||||
else
|
||||
tweet.appendChild(video2);
|
||||
//console.log("this should not happen!");
|
||||
break;
|
||||
}
|
||||
|
||||
if (nsfw) {
|
||||
tweet.appendChild(nsfw);
|
||||
nshow.addEventListener("click", () => {
|
||||
nsfw.classList.add("noff");
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
const qrtob = json["qrt"];
|
||||
|
||||
if ((Object.keys(qrtob).length === 0 && Object.getPrototypeOf(qrtob) === Object.prototype) == false) {
|
||||
//console.log(json["qrt"]);
|
||||
const qrt = createEl("div", "quote");
|
||||
const qname = createEl("div", "qname", { inner: `QRT of : ${qrtob.handle} (@${qrtob.screenname})` });
|
||||
json["qrt"]["desc"] = json["qrt"]["desc"].replaceAll(/http.*t.co\S+/g, "");
|
||||
const qdesc = createEl("div", "qdesc", { inner: qrtob.desc });
|
||||
qrt.appendChild(qname);
|
||||
qrt.appendChild(qdesc);
|
||||
tweet.appendChild(qrt);
|
||||
}
|
||||
|
||||
|
||||
const meta = createEl("div", "meta");
|
||||
|
||||
const rts = createEl("div", "cont", { inner: `${json["rts"]} Retweets` });
|
||||
const lks = createEl("div", "cont", { inner: `${json["likes"]} Likes` });
|
||||
|
||||
const share = createEl("img", "share", { src: "https://fxtwitter.com/copy.svg" });
|
||||
|
||||
meta.appendChild(rts);
|
||||
meta.appendChild(lks);
|
||||
meta.appendChild(share);
|
||||
tweet.appendChild(meta);
|
||||
bigArray.push(json["tweet"]);
|
||||
document.querySelector(".tweetCont").appendChild(tweet);
|
||||
document.querySelectorAll('img:not(.aimage,.share)').forEach(img => {
|
||||
imgPrev(img);
|
||||
});
|
||||
share.addEventListener("click", () =>
|
||||
navigator.clipboard.writeText(json["tweet"].replace("https://t", "https://fxt"))
|
||||
);
|
||||
|
||||
tweetCount++;
|
||||
} else {
|
||||
if (bigArray.length > 100) //pro memory management 😎
|
||||
bigArray = [];
|
||||
}
|
||||
}
|
429
static/style.css
429
static/style.css
|
@ -1,429 +0,0 @@
|
|||
@font-face {
|
||||
font-family: NotoColorEmojiLimited;
|
||||
unicode-range: U+1F1E6-1F1FF;
|
||||
src: url("https://fxtwitter.com/font.ttf");
|
||||
}
|
||||
|
||||
:root {
|
||||
--ios-height: 100vh;
|
||||
--top-height: calc(4.5vh + 1.25vw);
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
height: var(--ios-height);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
|
||||
a {
|
||||
color: unset;
|
||||
text-decoration: unset;
|
||||
}
|
||||
|
||||
a,
|
||||
a:link,
|
||||
a:focus,
|
||||
a:visited,
|
||||
a:active,
|
||||
a:-webkit-any-link,
|
||||
:link {
|
||||
color: unset;
|
||||
text-decoration: unset;
|
||||
}
|
||||
|
||||
a:hover {
|
||||
color: #8ebf42;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar {
|
||||
width: 1vmin;
|
||||
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-track {
|
||||
background: #171717;
|
||||
border-radius: .5vmin;
|
||||
margin: 2vmin 0 2vmin;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb {
|
||||
background: #e8e8e8;
|
||||
border-radius: .5vmin;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb:hover {
|
||||
background: #8ebf42;
|
||||
}
|
||||
|
||||
::selection {
|
||||
color: #171717;
|
||||
background-color: #e8e8e8;
|
||||
}
|
||||
|
||||
.base {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
font-family: 'Paytone One', 'NotoColorEmojiLimited', sans-serif;
|
||||
background-color: #222222;
|
||||
color: #e8e8e8;
|
||||
}
|
||||
|
||||
.top {
|
||||
height: var(--top-height);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
text-align: center;
|
||||
box-sizing: border-box;
|
||||
font-size: 7vmin;
|
||||
padding: 1vmin 0 1vmin;
|
||||
/*margin: 0 20vw 0;
|
||||
border-bottom: #e8e8e8 .1vmin solid;*/
|
||||
box-shadow: rgba(0, 0, 0, 0.2) 0px 1px 2px 0px;
|
||||
}
|
||||
|
||||
.top:hover {
|
||||
color: #8ebf42;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.bottom {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
}
|
||||
|
||||
.tweetCont {
|
||||
flex: 2;
|
||||
padding: calc(1vh + .25vw) 10% 0;
|
||||
|
||||
overflow-y: auto;
|
||||
max-height: calc(var(--ios-height) - var(--top-height) - calc(1vh + .25vw));
|
||||
}
|
||||
|
||||
.tweet {
|
||||
display: flex;
|
||||
position: relative;
|
||||
flex-direction: column;
|
||||
background-color: #171717;
|
||||
margin: 0 0 calc(2vh + .5vw);
|
||||
padding: 1vmin 0 1vmin;
|
||||
box-shadow: rgba(0, 0, 0, 0.4) 0px 4px 7px;
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
.side {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
max-height: calc(var(--ios-height) - var(--top-height) - calc(1vh + .25vw));
|
||||
}
|
||||
|
||||
.by {
|
||||
color: #8ebf42;
|
||||
}
|
||||
|
||||
.by:hover {
|
||||
color: #F74843;
|
||||
}
|
||||
|
||||
/* Tweet */
|
||||
.desc {
|
||||
padding: 0 calc(1.5vh + .25vw) 0;
|
||||
}
|
||||
|
||||
.auth,
|
||||
.meta {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
gap: 1%;
|
||||
font-size: 1.2em;
|
||||
padding: 0 calc(.5vh + .125vw) 0;
|
||||
}
|
||||
|
||||
.aname {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: space-evenly;
|
||||
}
|
||||
|
||||
.aname,
|
||||
.type {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.type {
|
||||
text-align: right;
|
||||
margin: auto 2% auto;
|
||||
}
|
||||
|
||||
.aimage {
|
||||
border-radius: 50%;
|
||||
border: #8ebf42 .3vmin solid;
|
||||
height: 100%;
|
||||
width: auto;
|
||||
margin: auto;
|
||||
/* No Drag */
|
||||
-webkit-user-drag: none;
|
||||
-khtml-user-drag: none;
|
||||
-moz-user-drag: none;
|
||||
-o-user-drag: none;
|
||||
}
|
||||
|
||||
.nsfw {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.ncont {
|
||||
position: absolute;
|
||||
z-index: 1;
|
||||
bottom: 20%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
gap: 2vmin;
|
||||
background-color: #17171788;
|
||||
border-radius: .5vmin;
|
||||
padding: 1vw;
|
||||
|
||||
}
|
||||
|
||||
.ninfo {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.nshow {
|
||||
padding: 1vh 1vw;
|
||||
background-color: #171717;
|
||||
border: solid .5vmin #8ebf42;
|
||||
color: #e8e8e8;
|
||||
border-radius: .5vmin;
|
||||
transition-duration: .2s;
|
||||
transition-timing-function: ease-in-out;
|
||||
cursor: pointer;
|
||||
user-select: none;
|
||||
font-size: 1em;
|
||||
}
|
||||
|
||||
|
||||
.nshow:hover {
|
||||
transform: scale(1.1);
|
||||
border: solid .5vmin #bf4242;
|
||||
}
|
||||
|
||||
.nshow:active {
|
||||
transform: scale(.98);
|
||||
}
|
||||
|
||||
.nsfw .media {
|
||||
filter: blur(30px);
|
||||
|
||||
}
|
||||
|
||||
.noff div:not(.imgCont) {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.noff .media {
|
||||
display: unset;
|
||||
filter: unset;
|
||||
}
|
||||
|
||||
.imgCont {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: center;
|
||||
flex-wrap: wrap;
|
||||
|
||||
|
||||
}
|
||||
|
||||
.imgCont .media {
|
||||
max-width: 50%;
|
||||
max-height: 35vh;
|
||||
}
|
||||
|
||||
.media {
|
||||
box-sizing: border-box;
|
||||
width: 100%;
|
||||
height: auto;
|
||||
max-height: 60vh;
|
||||
object-fit: scale-down;
|
||||
background-color: black;
|
||||
|
||||
}
|
||||
|
||||
.quote {
|
||||
margin: auto;
|
||||
width: 90%;
|
||||
border-radius: .5vmin;
|
||||
border: #222222 solid .5vmin;
|
||||
padding: .5vmin;
|
||||
}
|
||||
|
||||
.qname {
|
||||
color: #8ebf42;
|
||||
}
|
||||
|
||||
.cont,
|
||||
.date {
|
||||
margin: auto 0 auto;
|
||||
|
||||
}
|
||||
|
||||
.date {
|
||||
margin-left: 2%;
|
||||
}
|
||||
|
||||
.share {
|
||||
margin-left: auto;
|
||||
height: 2em;
|
||||
transition-duration: .2s;
|
||||
transition-timing-function: ease-in-out;
|
||||
}
|
||||
|
||||
.share:hover {
|
||||
transform: scale(.8);
|
||||
}
|
||||
|
||||
.share:active {
|
||||
transform: scale(2);
|
||||
}
|
||||
|
||||
.auth,
|
||||
.desc,
|
||||
.quote {
|
||||
margin-bottom: 2vmin;
|
||||
}
|
||||
|
||||
/* Settings */
|
||||
.settings,
|
||||
.info {
|
||||
font-size: 35px;
|
||||
padding: 1vmin;
|
||||
}
|
||||
|
||||
.settings {
|
||||
user-select: none;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.opt {
|
||||
font-size: .49em;
|
||||
user-select: none;
|
||||
white-space: nowrap;
|
||||
flex-wrap: nowrap;
|
||||
}
|
||||
|
||||
.Iinner {
|
||||
font-size: .5em;
|
||||
}
|
||||
|
||||
/* Preview */
|
||||
|
||||
img:not(.previmg, .aimage) {
|
||||
cursor: pointer;
|
||||
transition-duration: .2s;
|
||||
transition-timing-function: ease-in-out;
|
||||
}
|
||||
|
||||
.previmgcont {
|
||||
position: fixed;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
flex-direction: column;
|
||||
top: 0%;
|
||||
left: 0%;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
z-index: 101;
|
||||
background-color: #171717b7;
|
||||
}
|
||||
|
||||
.previmg {
|
||||
margin: auto;
|
||||
cursor: zoom-out !important;
|
||||
max-width: 100vw;
|
||||
max-height: 100vh;
|
||||
min-width: 100vw;
|
||||
object-fit: contain;
|
||||
}
|
||||
|
||||
/* Block */
|
||||
|
||||
#block {
|
||||
position: fixed;
|
||||
box-sizing: border-box;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
z-index: 99;
|
||||
background: #222222;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: calc(1.75vh + .25vw);
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
#block .warn {
|
||||
font-size: 2em;
|
||||
color: #F74843;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.boptions {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
gap: 1.5vmin;
|
||||
}
|
||||
|
||||
.boptions>div {
|
||||
padding: 2vh 2vw;
|
||||
border: solid .5vmin #c5c5c5;
|
||||
color: #e8e8e8;
|
||||
border-radius: .5vmin;
|
||||
transition-duration: .15s;
|
||||
transition-timing-function: ease-in-out;
|
||||
cursor: pointer;
|
||||
user-select: none;
|
||||
font-size: 1em;
|
||||
}
|
||||
|
||||
.boptions>div:hover {
|
||||
transform: scale(1.02);
|
||||
border: solid .5vmin #8ebf42;
|
||||
}
|
||||
|
||||
.boptions>div:active {
|
||||
transform: scale(.98);
|
||||
}
|
||||
|
||||
@media (max-aspect-ratio: 4/4),
|
||||
(max-height: 500px),
|
||||
(max-width: 1100px) {
|
||||
.side {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.tweet {
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.tweetCont {
|
||||
padding: 0 5% 0;
|
||||
}
|
||||
|
||||
.boptions {
|
||||
flex-direction: column;
|
||||
}
|
||||
}
|
|
@ -1,133 +0,0 @@
|
|||
{% extends 'base.html' %}
|
||||
|
||||
{% block head %}
|
||||
<title> TwitFix {{ page }}</title>
|
||||
<script>
|
||||
window.onload = () => {
|
||||
document.querySelector("#block>div").addEventListener('click', () => document.getElementById("block").style.display = "none");
|
||||
document.getElementById("another").addEventListener('click', () => window.location.reload());
|
||||
document.getElementById("copy").addEventListener('click', () => navigator.clipboard.writeText('{{ vidlink }}'));
|
||||
};
|
||||
</script>
|
||||
<style>
|
||||
@import url('https://fonts.googleapis.com/css2?family=Bowlby+One+SC&family=Paytone+One&display=swap');
|
||||
@import url('https://fonts.googleapis.com/css2?family=Source+Code+Pro:wght@500&display=swap');
|
||||
html,
|
||||
body {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
body {
|
||||
text-align: center;
|
||||
background: #222222;
|
||||
color: #e8e8e8;
|
||||
font-family: 'Paytone One', sans-serif;
|
||||
font-size: 4vmin;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: space-evenly;
|
||||
align-items: center;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
body div {
|
||||
font-size: 75%;
|
||||
}
|
||||
|
||||
video {
|
||||
box-sizing: border-box;
|
||||
height: auto;
|
||||
width: auto;
|
||||
max-width: 80%;
|
||||
max-height: 80%;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
a {
|
||||
color: #8ebf42;
|
||||
}
|
||||
|
||||
a:hover {
|
||||
color: #e8e8e8;
|
||||
}
|
||||
|
||||
#block {
|
||||
position: fixed;
|
||||
box-sizing: border-box;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
z-index: 99;
|
||||
background: #222222;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
#block>div {
|
||||
padding: 2vh 2vw;
|
||||
border: solid .5vmin #c5c5c5;
|
||||
border-radius: .5vmin;
|
||||
transition-duration: .15s;
|
||||
transition-timing-function: ease-in-out;
|
||||
cursor: pointer;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
#block>div:hover {
|
||||
transform: scale(1.02);
|
||||
border: solid .5vmin #8ebf42;
|
||||
}
|
||||
|
||||
#block>div:active {
|
||||
transform: scale(.98);
|
||||
}
|
||||
|
||||
#btns {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: center;
|
||||
gap: 1vmax;
|
||||
}
|
||||
|
||||
#btns div {
|
||||
cursor: pointer;
|
||||
border: solid .3vmin #c5c5c5;
|
||||
border-radius: .3vmin;
|
||||
padding: .3vmin;
|
||||
}
|
||||
|
||||
#btns div:hover {
|
||||
border: solid .3vmin #8ebf42;
|
||||
}
|
||||
</style>
|
||||
<link rel="alternate" href="{{ url }}/oembed.json?desc={{ urlUser }}&user={{ urlDesc }}&link={{ urlLink }}" type="application/json+oembed" title="{{ user }}">
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
|
||||
<div id="block">
|
||||
<div>
|
||||
Potentially NSFW Content: Click here if you are over 18
|
||||
</div>
|
||||
</div>
|
||||
<div><a href="{{ repo }}">TwitFix</a> {{ page }} Video</div>
|
||||
<div>WARNING: Video content is not screened so it may contain NSFW Content</div>
|
||||
<video width="720" height="480" controls>
|
||||
<source src="{{ vidlink }}" type="video/mp4">
|
||||
</video>
|
||||
<div id="btns">
|
||||
<div id="another">Another?</div>
|
||||
<div id="copy">Copy Link!</div>
|
||||
</div>
|
||||
<div>
|
||||
<a href="{{ tweet }}">Original Tweet</a>
|
||||
<div>
|
||||
Original Author: {{ user }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
|
@ -1,76 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Twitfix Latest</title>
|
||||
<link rel="stylesheet" href={{ url_for('static', filename='style.css' ) }}>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Paytone+One&display=swap" rel="stylesheet">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<script src={{ url_for('static', filename='main.js' ) }}></script>
|
||||
|
||||
<div class="previmgcont" onclick="document.querySelector('.previmgcont').style.display = 'none'; "
|
||||
style="display: none;">
|
||||
<img loading=lazy class="previmg" alt="Image Preview">
|
||||
</div>
|
||||
|
||||
<div class="base">
|
||||
<div id="block">
|
||||
<p class="warn">Warning!!</p>
|
||||
<p>Twitfix only filters the content specified as NSFW.</p>
|
||||
<p>Following content might be NSFW.</p>
|
||||
<p>Prepare yourself mentally and pick one of the options</p>
|
||||
<p>Do you want to see the latest twitfix requests?</p>
|
||||
<br>
|
||||
<div class="boptions">
|
||||
<div onclick="cookieTime()">Yes, don't ask again!</div>
|
||||
<div onclick="forNow()">Yes, for now.</div>
|
||||
<div onclick="window.location.replace('https://github.com/robinuniverse/TwitFix')">No, please take me
|
||||
out of here</div>
|
||||
</div>
|
||||
</div>
|
||||
<a href="https://github.com/robinuniverse/TwitFix" class="top" rel="noreferrer" target="_blank">TwitFix
|
||||
Latest</a>
|
||||
<div class="bottom">
|
||||
<div class="info side">
|
||||
<div>TwitFix</div>
|
||||
<div class="Iinner">
|
||||
Basic flask server that serves fixed twitter video embeds to desktop discord by using either the
|
||||
Twitter API or Youtube-DL to grab tweet video information. This also automatically embeds the first
|
||||
link in the text of non video tweets (API Only).
|
||||
</div>
|
||||
<br>
|
||||
<div>TwitFix Latest</div>
|
||||
<div class="Iinner">
|
||||
Shows the most recent TwitFix API requests in a list like manner.
|
||||
</div>
|
||||
<br>
|
||||
<div class="Iinner">
|
||||
TwitFix by <a href="https://hirob.in/" target="_blank" rel="noopener noreferrer">Robin
|
||||
✨Universe</a><br><br>
|
||||
Site Design by <a href="https://twitter.com/doruksega" target="_blank"
|
||||
rel="noopener noreferrer">Doruk</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="tweetCont">
|
||||
</div>
|
||||
<div class="settings side">
|
||||
<div>Settings</div>
|
||||
<div>
|
||||
<input type="checkbox" id="contwarn" name="contwarn">
|
||||
<label class="opt" for="contwarn">Skip Content Warning</label>
|
||||
</div>
|
||||
<div>
|
||||
<input type="checkbox" id="notsafe" name="notsafe">
|
||||
<label class="opt" for="notsafe">Don't Hide NSFW Tweets</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
|
@ -1,43 +0,0 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>TwitFix Stats</title>
|
||||
<style>
|
||||
|
||||
</style>
|
||||
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
|
||||
<script type="text/javascript">
|
||||
google.charts.load('current', {'packages':['bar']});
|
||||
google.charts.setOnLoadCallback(drawStuff);
|
||||
|
||||
function drawStuff() {
|
||||
var data = new google.visualization.arrayToDataTable([
|
||||
['Move', 'requests'],
|
||||
["Cached Links Loaded", {{ embeds }}],
|
||||
["New Unique Links Cached", {{ linksCached }}],
|
||||
["API Calls", {{ api }}],
|
||||
["Direct Videos Downloaded", {{ downloadss }}]
|
||||
]);
|
||||
|
||||
var options = {
|
||||
width: 800,
|
||||
legend: { position: 'none' },
|
||||
axes: {
|
||||
x: {
|
||||
0: { side: 'top', label: 'Data Gathered for {{ date }}'} // Top x-axis.
|
||||
}
|
||||
},
|
||||
bar: { groupWidth: "90%" }
|
||||
};
|
||||
|
||||
var chart = new google.charts.Bar(document.getElementById('top_x_div'));
|
||||
// Convert the Classic options to Material options.
|
||||
chart.draw(data, google.charts.Bar.convertOptions(options));
|
||||
};
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="center">
|
||||
<div id="top_x_div" style="width: 800px; height: 600px; display: block; margin: 0 auto;"></div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
172
twitfix.py
172
twitfix.py
|
@ -82,86 +82,6 @@ elif link_cache_system == "db":
|
|||
table = config['config']['table']
|
||||
db = client[table]
|
||||
|
||||
@app.route('/stats/')
|
||||
def statsPage():
|
||||
today = str(date.today())
|
||||
stats = getStats(today)
|
||||
return render_template('stats.html', embeds=stats['embeds'], downloadss=stats['downloads'], api=stats['api'], linksCached=stats['linksCached'], date=today)
|
||||
|
||||
@app.route('/latest/')
|
||||
def latest():
|
||||
return render_template('latest.html')
|
||||
|
||||
@app.route('/copy.svg') # Return a SVG needed for Latest
|
||||
def icon():
|
||||
return send_from_directory(os.path.join(app.root_path, 'static'),
|
||||
'copy.svg',mimetype='image/svg+xml')
|
||||
|
||||
@app.route('/font.ttf') # Return a font needed for Latest
|
||||
def font():
|
||||
return send_from_directory(os.path.join(app.root_path, 'static'),
|
||||
'NotoColorEmoji.ttf',mimetype='application/octet-stream')
|
||||
|
||||
@app.route('/top/') # Try to return the most hit video
|
||||
def top():
|
||||
vnf = db.linkCache.find_one(sort = [('hits', pymongo.DESCENDING)])
|
||||
desc = re.sub(r' http.*t\.co\S+', '', vnf['description'])
|
||||
urlUser = urllib.parse.quote(vnf['uploader'])
|
||||
urlDesc = urllib.parse.quote(desc)
|
||||
urlLink = urllib.parse.quote(vnf['url'])
|
||||
print(" ➤ [ ✔ ] Top video page loaded: " + vnf['tweet'] )
|
||||
return render_template('inline.html', page="Top", vidlink=vnf['url'], vidurl=vnf['url'], desc=desc, pic=vnf['thumbnail'], user=vnf['uploader'], video_link=vnf['url'], color=config['config']['color'], appname=config['config']['appname'], repo=config['config']['repo'], url=config['config']['url'], urlDesc=urlDesc, urlUser=urlUser, urlLink=urlLink, tweet=vnf['tweet'])
|
||||
|
||||
@app.route('/api/latest/') # Return some raw VNF data sorted by top tweets
|
||||
def apiLatest():
|
||||
bigvnf = []
|
||||
|
||||
tweets = request.args.get("tweets", default=10, type=int)
|
||||
page = request.args.get("page", default=0, type=int)
|
||||
|
||||
if tweets > 15:
|
||||
tweets = 1
|
||||
|
||||
vnf = db.linkCache.find(sort = [('_id', pymongo.DESCENDING)]).skip(tweets * page).limit(tweets)
|
||||
|
||||
for r in vnf:
|
||||
bigvnf.append(r)
|
||||
|
||||
print(" ➤ [ ✔ ] Latest video API called")
|
||||
addToStat('api')
|
||||
return Response(response=json.dumps(bigvnf, default=str), status=200, mimetype="application/json")
|
||||
|
||||
@app.route('/api/top/') # Return some raw VNF data sorted by top tweets
|
||||
def apiTop():
|
||||
bigvnf = []
|
||||
|
||||
tweets = request.args.get("tweets", default=10, type=int)
|
||||
page = request.args.get("page", default=0, type=int)
|
||||
|
||||
if tweets > 15:
|
||||
tweets = 1
|
||||
|
||||
vnf = db.linkCache.find(sort = [('hits', pymongo.DESCENDING )]).skip(tweets * page).limit(tweets)
|
||||
|
||||
for r in vnf:
|
||||
bigvnf.append(r)
|
||||
|
||||
print(" ➤ [ ✔ ] Top video API called")
|
||||
addToStat('api')
|
||||
return Response(response=json.dumps(bigvnf, default=str), status=200, mimetype="application/json")
|
||||
|
||||
@app.route('/api/stats/') # Return a json of a usage stats for a given date (defaults to today)
|
||||
def apiStats():
|
||||
try:
|
||||
addToStat('api')
|
||||
today = str(date.today())
|
||||
desiredDate = request.args.get("date", default=today, type=str)
|
||||
stat = getStats(desiredDate)
|
||||
print (" ➤ [ ✔ ] Stats API called")
|
||||
return Response(response=json.dumps(stat, default=str), status=200, mimetype="application/json")
|
||||
except:
|
||||
print (" ➤ [ ✔ ] Stats API failed")
|
||||
|
||||
@app.route('/') # If the useragent is discord, return the embed, if not, redirect to configured repo directly
|
||||
def default():
|
||||
user_agent = request.headers.get('user-agent')
|
||||
|
@ -184,9 +104,9 @@ def twitfix(sub_path):
|
|||
match = pathregex.search(sub_path)
|
||||
print(request.url)
|
||||
|
||||
if request.url.startswith("https://d.fx"): # Matches d.fx? Try to give the user a direct link
|
||||
if request.url.startswith("https://d.vx"): # Matches d.fx? Try to give the user a direct link
|
||||
if user_agent in generate_embed_user_agents:
|
||||
print( " ➤ [ D ] d.fx link shown to discord user-agent!")
|
||||
print( " ➤ [ D ] d.vx link shown to discord user-agent!")
|
||||
if request.url.endswith(".mp4") and "?" not in request.url:
|
||||
return dl(sub_path)
|
||||
else:
|
||||
|
@ -205,22 +125,22 @@ def twitfix(sub_path):
|
|||
|
||||
return dl(clean)
|
||||
|
||||
elif request.url.endswith(".json") or request.url.endswith("%2Ejson"):
|
||||
twitter_url = "https://twitter.com/" + sub_path
|
||||
# elif request.url.endswith(".json") or request.url.endswith("%2Ejson"):
|
||||
# twitter_url = "https://twitter.com/" + sub_path
|
||||
|
||||
if "?" not in request.url:
|
||||
clean = twitter_url[:-5]
|
||||
else:
|
||||
clean = twitter_url
|
||||
# if "?" not in request.url:
|
||||
# clean = twitter_url[:-5]
|
||||
# else:
|
||||
# clean = twitter_url
|
||||
|
||||
print( " ➤ [ API ] VNF Json api hit!")
|
||||
# print( " ➤ [ API ] VNF Json api hit!")
|
||||
|
||||
vnf = link_to_vnf_from_api(clean.replace(".json",""))
|
||||
# vnf = link_to_vnf_from_api(clean.replace(".json",""))
|
||||
|
||||
if user_agent in generate_embed_user_agents:
|
||||
return message("VNF Data: ( discord useragent preview )\n\n"+ json.dumps(vnf, default=str))
|
||||
else:
|
||||
return Response(response=json.dumps(vnf, default=str), status=200, mimetype="application/json")
|
||||
# if user_agent in generate_embed_user_agents:
|
||||
# return message("VNF Data: ( discord useragent preview )\n\n"+ json.dumps(vnf, default=str))
|
||||
# else:
|
||||
# return Response(response=json.dumps(vnf, default=str), status=200, mimetype="application/json")
|
||||
|
||||
elif request.url.endswith("/1") or request.url.endswith("/2") or request.url.endswith("/3") or request.url.endswith("/4") or request.url.endswith("%2F1") or request.url.endswith("%2F2") or request.url.endswith("%2F3") or request.url.endswith("%2F4"):
|
||||
twitter_url = "https://twitter.com/" + sub_path
|
||||
|
@ -249,51 +169,6 @@ def twitfix(sub_path):
|
|||
else:
|
||||
return message("This doesn't appear to be a twitter URL")
|
||||
|
||||
@app.route('/other/<path:sub_path>') # Show all info that Youtube-DL can get about a video as a json
|
||||
def other(sub_path):
|
||||
otherurl = request.url.split("/other/", 1)[1].replace(":/","://")
|
||||
print(" ➤ [ OTHER ] Other URL embed attempted: " + otherurl)
|
||||
res = embed_video(otherurl)
|
||||
return res
|
||||
|
||||
@app.route('/info/<path:sub_path>') # Show all info that Youtube-DL can get about a video as a json
|
||||
def info(sub_path):
|
||||
infourl = request.url.split("/info/", 1)[1].replace(":/","://")
|
||||
print(" ➤ [ INFO ] Info data requested: " + infourl)
|
||||
with youtube_dl.YoutubeDL({'outtmpl': '%(id)s.%(ext)s'}) as ydl:
|
||||
result = ydl.extract_info(infourl, download=False)
|
||||
|
||||
return result
|
||||
|
||||
@app.route('/dl/<path:sub_path>') # Download the tweets video, and rehost it
|
||||
def dl(sub_path):
|
||||
print(' ➤ [[ !!! TRYING TO DOWNLOAD FILE !!! ]] Downloading file from ' + sub_path)
|
||||
url = sub_path
|
||||
match = pathregex.search(url)
|
||||
if match is not None:
|
||||
twitter_url = url
|
||||
if match.start() == 0:
|
||||
twitter_url = "https://twitter.com/" + url
|
||||
|
||||
mp4link = direct_video_link(twitter_url)
|
||||
filename = (sub_path.split('/')[-1].split('.mp4')[0] + '.mp4')
|
||||
|
||||
PATH = ( './static/' + filename )
|
||||
if os.path.isfile(PATH) and os.access(PATH, os.R_OK):
|
||||
print(" ➤ [[ FILE EXISTS ]]")
|
||||
else:
|
||||
print(" ➤ [[ FILE DOES NOT EXIST, DOWNLOADING... ]]")
|
||||
addToStat('downloads')
|
||||
mp4file = urllib.request.urlopen(mp4link)
|
||||
with open(('/home/robin/twitfix/static/' + filename), 'wb') as output:
|
||||
output.write(mp4file.read())
|
||||
|
||||
print(' ➤ [[ PRESENTING FILE: '+ filename +', URL: https://fxtwitter.com/static/'+ filename +' ]]')
|
||||
r = make_response(send_file(('static/' + filename), mimetype='video/mp4', max_age=100))
|
||||
r.headers['Content-Type'] = 'video/mp4'
|
||||
r.headers['Sec-Fetch-Site'] = 'none'
|
||||
r.headers['Sec-Fetch-User'] = '?1'
|
||||
return r
|
||||
|
||||
@app.route('/dir/<path:sub_path>') # Try to return a direct link to the MP4 on twitters servers
|
||||
def dir(sub_path):
|
||||
|
@ -351,23 +226,6 @@ def direct_video_link(video_link): # Just get a redirect to a MP4 link from any
|
|||
return cached_vnf['url']
|
||||
print(" ➤ [ D ] Redirecting to direct URL: " + vnf['url'])
|
||||
|
||||
def addToStat(stat):
|
||||
#print(stat)
|
||||
today = str(date.today())
|
||||
try:
|
||||
collection = db.stats.find_one({'date': today})
|
||||
delta = ( collection[stat] + 1 )
|
||||
query = { "date" : today }
|
||||
change = { "$set" : { stat : delta } }
|
||||
out = db.stats.update_one(query, change)
|
||||
except:
|
||||
collection = db.stats.insert_one({'date': today, "embeds" : 1, "linksCached" : 1, "api" : 1, "downloads" : 1 })
|
||||
|
||||
|
||||
def getStats(day):
|
||||
collection = db.stats.find_one({'date': day})
|
||||
return collection
|
||||
|
||||
def embed_video(video_link, image=0): # Return Embed from any tweet link
|
||||
cached_vnf = getVnfFromLinkCache(video_link)
|
||||
|
||||
|
@ -511,7 +369,6 @@ def getVnfFromLinkCache(video_link):
|
|||
query = { 'tweet': video_link }
|
||||
change = { "$set" : { "hits" : hits } }
|
||||
out = db.linkCache.update_one(query, change)
|
||||
addToStat('embeds')
|
||||
return vnf
|
||||
else:
|
||||
print(" ➤ [ X ] Link not in DB cache")
|
||||
|
@ -530,7 +387,6 @@ def addVnfToLinkCache(video_link, vnf):
|
|||
try:
|
||||
out = db.linkCache.insert_one(vnf)
|
||||
print(" ➤ [ + ] Link added to DB cache ")
|
||||
addToStat('linksCached')
|
||||
return True
|
||||
except Exception:
|
||||
print(" ➤ [ X ] Failed to add link to DB cache")
|
||||
|
|
Loading…
Reference in a new issue