Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="UTF-8">
- <link rel="shortcut icon" type="image/x-icon" href="http://localhost:8000/8ch/favicon.ico"/>
- <style>
- body {
- background:#EEF2FF;
- font:10pt arial,helvetica,sans-serif;
- }
- .boardlist {
- background-color:#EEF2FF;
- position:fixed;
- width:100%;
- z-index:998;
- }
- .spacer {
- width:100%;
- height:40px;
- }
- .reply {
- background:#D6DAF0;
- display:inline-block;
- max-width:94%;
- border-color:#B7C5D9;
- border-style:none solid solid none;
- border-width:1px;
- margin:.2em 4px;
- padding:.5em .3em .5em .6em;
- }
- .intro {
- clear:none;
- margin:.5em 0;
- padding:0 0 .2em;
- }
- .zoom {
- pointer-events:none;
- }
- .intro span.subject {
- color:#0F0C5D;
- font-weight:700;
- float:left;
- margin-right:1em;
- }
- .intro span.name {
- color:#117743;
- font-weight:700;
- float:left;
- margin-right:1em;
- }
- .fileinfo {
- display:block;
- position:relative;
- }
- .file {
- margin-right:2px;
- float:left;
- position:relative;
- }
- .post-imagexxx {
- clear:both;
- }
- .img {
- clear:both;
- position:relative;
- width:100%;
- }
- a,a:visited {
- color:#34345C;
- text-decoration:underline;
- }
- a.post_no {
- text-decoration:none;
- margin:0;
- padding:0;
- }
- .intro a.post_no {
- color:inherit;
- }
- .intro a.post_no,p.intro a.email,p.intro a.post_anchor {
- margin:0;
- }
- .file:not(.multifile) {
- float:none;
- }
- .intro a {
- margin-left:5px;
- }
- div.post p {
- display:block;
- font-size:13px;
- line-height:1.16em;
- min-height:1.16em;
- margin:0;
- }
- div.post div.body {
- margin-top:.8em;
- padding-bottom:.3em;
- padding-right:3em;
- white-space:pre-wrap;
- word-wrap:break-word;
- clear:none;
- }
- div.post.reply div.body {
- margin-left:1.8em;
- }
- div.post.reply div.body a {
- color:#D00;
- }
- .quote {
- color:#789922;
- }
- span.heading {
- color:#AF0A0F;
- font-size:11pt;
- font-weight:700;
- }
- span.spoiler {
- background:#000;
- color:#000;
- padding:0 1px;
- }
- pre {
- display:block!important;
- font:9pt monospace;
- max-width:inherit;
- overflow:auto;
- word-wrap:normal;
- margin:0 display:inline!important;
- }
- .intro,div.post div.body {
- clear:none;
- }
- .ltr {
- direction:ltr;
- }
- div.boardlist {
- color:#89A;
- font-size:9pt;
- margin-top:3px;
- }
- div.boardlist a {
- text-decoration:none;
- }
- div.post.reply {
- background:#D6DAF0;
- display:inline-block;
- max-width:94%!important;
- border-color:#B7C5D9;
- border-style:none solid solid none;
- border-width:1px;
- margin:.2em 4px;
- padding:.5em .3em .5em .6em;
- }
- #largeImage {
- position:fixed;
- top:0;
- right:0;
- max-height:100%;
- z-index:999;
- }
- .thread div.files div.file,.body,.thread div.op div.files div.file,.file,.body {
- float:left;
- position:relative;
- }
- .intro span.hide,.intro span.time,.intro span.hide,.intro span.time {
- float:left;
- margin-right:1em;
- }
- .thread div.post,.thread div.op,.post,.op,.post,.thread div.op,.thread div.post,.op,.post,.thread div.op,.thread div.post {
- float:left;
- position:relative;
- width:100%;
- }
- </style>
- <base href="https://8ch.net/">
- </head>
- <body>
- <div class="boardlist">
- <span class="favorite-boards"> [
- <a href="http://8ch.net/index.html"><i class="fa fa-home" title="Home"></i>home</a> ]
- [
- <a href="" id="v" onclick='setThroughLink(this); return false;'>v</a> /
- <a href="" id="tech" onclick='setThroughLink(this); return false;'>tech</a> /
- <a href="" id="agdg" onclick='setThroughLink(this); return false;'>agdg</a> /
- <a href="" id="robowaifu" onclick='setThroughLink(this); return false;'>robowaifu</a> /
- <a href="" id="hydrus" onclick='setThroughLink(this); return false;'>hydrus</a> ]
- [
- <a href="" id="f" onclick='setThroughLink(this); return false;'>f</a> /
- <a href="" id="hgg" onclick='setThroughLink(this); return false;'>hgg</a> /
- <a href="" id="htg" onclick='setThroughLink(this); return false;'>htg</a> /
- <a href="" id="b" onclick='setThroughLink(this); return false;'>b</a> /
- <a href="" id="pol" onclick='setThroughLink(this); return false;'>pol</a> /
- <a href="" id="3d" onclick='setThroughLink(this); return false;'>3d</a> /
- <a href="" id="delicious" onclick='setThroughLink(this); return false;'>delicious</a> /
- <a href="" id="liru" onclick='setThroughLink(this); return false;'>liru</a> ]
- </span>
- <span id="filterManager">
- </span>
- </div>
- <div class="zoom">
- <img id="largeImage" src="" />
- </div>
- <div class="spacer"> </div>
- </body>
- <script>
- var board
- var templist = []
- var blacklist = {}
- function setThroughLink(yourLink){
- removeDummy()
- board = yourLink.id
- console.log("current board: " + board)
- blacklist[board] = []
- filterManager()
- console.log("showing filter array")
- console.log(blacklist)
- start()
- }
- function removeDummy(){
- console.log("clearing screen")
- var elem = document.getElementsByClassName("thread")
- //console.log(elem)
- while (elem[0]){
- elem[0].remove()
- }
- return false;
- }
- async function start(){
- let urls = await get_url_list(board)
- let pages_json = await fetch_all_urls(urls)
- let thread_list = await filter_and_bump_order_threads(pages_json)
- //console.log(thread_list)
- console.log("all pages parsed")
- let keys = await Object.keys(thread_list)
- for (i = keys.length - 1; i >= 0; i--) {
- display_thread(thread_list[keys[i]])
- }
- }
- async function get_url_list(board){
- let response = await fetch("https://8ch.net/" + board + "/threads.json")
- let board_data = await response.json()
- let pages = board_data.length
- let urls = []
- for (i = 0; i < pages; i++){
- urls.push("https://8ch.net/" + board + "/" + i + ".json")
- }
- return urls
- }
- async function fetch_all_urls(urls){
- try{
- var data = await Promise.all(urls.map(url =>fetch(url).then((response) => response.json())))
- return (data)
- }
- catch (error) {
- console.log(error)
- throw (error)
- }
- }
- async function filter_and_bump_order_threads(pages_json){
- let bump_order = {}
- let pages = pages_json.length
- for (i = 0; i < pages; i++){
- //console.log(pages_json[i].threads)
- for (var a of pages_json[i].threads) {
- if (!(blacklist[board].indexOf(a.posts[0].no) >= 0)) { /*if thread is NOT in blacklist array add it*/
- bump_order[a.posts[a.posts.length-1].last_modified] = a.posts
- }
- }
- }
- //console.log(bump_order)
- return bump_order
- }
- async function display_thread(thread){
- var is_op = true
- for(post of thread){
- if (is_op){
- var no = post.no
- var com = post.com
- var filename = post.filename
- var ext = post.ext
- var tim = post.tim
- var fsize = post.fsize
- var name = post.name
- var w = post.w
- var h = post.h
- var tn_w = post.tn_w
- var tn_h = post.tn_h
- var sub = post.sub
- if (sub == null){sub=""}
- var time = post.time
- threadidop = "thread_" + no
- var hh = "hide_" + no
- var imagelink = "https://media.8ch.net/file_store/" + tim + ext
- //replies
- var newDiv = document.createElement("div")
- newDiv.setAttribute("class", "thread")
- newDiv.setAttribute("id", "thread_" + no)
- newDiv.setAttribute("data-board", board)
- if (blacklist[board].indexOf(no) >= 0){
- newDiv.setAttribute("style", "display: none")
- }
- var elements = newDiv.childNodes
- var op = document.createElement("div")
- op.setAttribute("class", "op")
- var intro = document.createElement("div")
- intro.setAttribute("class", "intro")
- var hid = document.createElement("BUTTON")
- hid.setAttribute("onclick", "hide_thread(" + no + ")")
- var t = document.createTextNode("Hide")
- hid.appendChild(t)
- var hide = document.createElement("span")
- hide.setAttribute("class", "hide")
- hide.appendChild(hid)
- intro.appendChild(hide)
- var subject = document.createElement("span")
- subject.setAttribute("class", "subject")
- subject.innerHTML = sub
- intro.appendChild(subject)
- var name = document.createElement("span")
- name.setAttribute("class", "name")
- name.innerHTML = post.name
- intro.appendChild(name)
- var time = document.createElement("span")
- time.setAttribute("class", "time")
- time.innerHTML = timeAgoFromEpochTime(post.time)
- intro.appendChild(time)
- var post_no = document.createElement("a")
- post_no.setAttribute("class", "post_no")
- post_no.setAttribute("href", "http://8ch.net/" + board + "/res/" + no + ".html")
- post_no.innerHTML = post.no
- intro.appendChild(post_no)
- op.appendChild(intro)
- /////////////////////////////////////////////////////////////////////////////////////////
- create_post(op, post)
- /////////////////////////////////////////////////////////////////////////////////////////
- newDiv.appendChild(op)
- document.body.appendChild(newDiv)
- is_op = false
- }
- else{
- var no = post.no
- var com = post.com
- var name = post.name
- var time = post.time
- //replies
- var newDiv = document.createElement("div")
- newDiv.setAttribute("class", "post reply")
- newDiv.setAttribute("id", "reply_" + no)
- var intro = document.createElement("div")
- intro.setAttribute("class", "intro")
- var name = document.createElement("span")
- name.setAttribute("class", "name")
- name.innerHTML = post.name
- intro.appendChild(name)
- var time = document.createElement("span")
- time.setAttribute("class", "time")
- time.innerHTML = timeAgoFromEpochTime(post.time)
- intro.appendChild(time)
- intro.appendChild(document.createElement("span")).innerHTML = no
- newDiv.appendChild(intro)
- create_post(newDiv,post)
- document.getElementById(threadidop).appendChild(newDiv)
- }
- }
- }
- function hide_thread(n){
- blacklist[board].push(n)
- localStorage.setItem("blacklist", JSON.stringify(blacklist))
- var hideDiv = document.getElementById("thread_" + n)
- hideDiv.setAttribute("style", "display: none")
- }
- function create_post(parent, array){
- //thread/op-reply/intro-files-body (function does files and body to parent op or post reply)
- if (!(array.filename == null)) { //if at least a image is present
- var files = document.createElement("div")
- files.setAttribute("class", "files")
- create_file(files, array) //do image
- if (!(array.extra_files == null)){ //if extra images present
- for (var i of array.extra_files){
- create_file(files, i)
- }
- }
- parent.appendChild(files)
- }
- var body = document.createElement("div")
- body.setAttribute("class", "body")
- body.innerHTML = array.com
- parent.appendChild(body)
- }
- function create_file(parent, array){
- var file = document.createElement("div")
- file.setAttribute("class", "file")
- var fileinfo = document.createElement("span")
- fileinfo.setAttribute("class", "fileinfo")
- var trunc = array.filename
- if (trunc.length > 26){
- trunc = trunc.substring(0,24)+"…"
- }
- var imageOriginal = "https://media.8ch.net/file_store/" + array.tim + array.ext + "/" + trunc + array.ext
- var imageHashed = "https://media.8ch.net/file_store/" + array.tim + array.ext
- var imageThumbnail = "https://media.8ch.net/file_store/thumb/" + array.tim + array.ext
- if (array.ext == ".webm" || array.ext == ".mp4"){
- imageThumbnail = "https://media.8ch.net/file_store/thumb/" + array.tim + ".jpg"
- }
- //fileinfo.innerHTML = "<span>File : </span><a title=\"" + array.filename + "\" href=" + imageOriginal + ">" + trunc + array.ext + "</a><span class=\"unimportant\"> (" + array.fsize + ", " + array.w + "x" + array.h + ")</span>"
- var span1 = document.createElement("span")
- span1.innerHTML = "File : "
- var linktoimage = document.createElement("a")
- //linktoimage.setAttribute("title", array.filename)
- linktoimage.setAttribute("href", imageOriginal)
- linktoimage.setAttribute("download", "ffff")
- linktoimage.innerHTML = trunc + array.ext
- var span2 = document.createElement("span")
- span2.innerHTML = " (" + array.fsize + ", " + array.w + "x" + array.h + ")"
- fileinfo.appendChild(span1)
- fileinfo.appendChild(linktoimage)
- fileinfo.appendChild(span2)
- file.appendChild(fileinfo)
- var image = document.createElement("a")
- var imagelink = "https://media.8ch.net/file_store/thumb/" + array.tim + array.ext
- image.setAttribute("href", imageOriginal)
- image.setAttribute("class", "img")
- image.setAttribute("id", "img")
- image.innerHTML = "<img class=\"post-imagexxx\" onmouseover=\"bigImg(this)\" onmouseleave=\"normalImg(this)\"src=" + imageThumbnail + " style=\"width:" + array.tn_w + "px;height:" + array.tn_h + "px\">"
- file.appendChild(image)
- parent.appendChild(file)
- }
- function timeAgoFromEpochTime(epoch) {
- var secs = ((new Date()).getTime() / 1000) - epoch;
- Math.floor(secs);
- var minutes = secs / 60;
- secs = Math.floor(secs % 60);
- if (minutes < 1) {
- return secs + (secs > 1 ? ' seconds ago' : ' second ago');
- }
- var hours = minutes / 60;
- minutes = Math.floor(minutes % 60);
- if (hours < 1) {
- return minutes + (minutes > 1 ? ' minutes ago' : ' minute ago');
- }
- var days = hours / 24;
- hours = Math.floor(hours % 24);
- if (days < 1) {
- return hours + (hours > 1 ? ' hours ago' : ' hour ago');
- }
- var weeks = days / 7;
- days = Math.floor(days % 7);
- if (weeks < 1) {
- return days + (days > 1 ? ' days ago' : ' day ago');
- }
- var months = weeks / 4.35;
- weeks = Math.floor(weeks % 4.35);
- if (months < 1) {
- return weeks + (weeks > 1 ? ' weeks ago' : ' week ago');
- }
- var years = months / 12;
- months = Math.floor(months % 12);
- if (years < 1) {
- return months + (months > 1 ? ' months ago' : ' month ago');
- }
- years = Math.floor(years);
- return years + (years > 1 ? ' years ago' : ' years ago');
- }
- function bigImg(thiis){
- console.log(thiis.parentElement)
- console.log(thiis.parentElement.getAttribute("href"))
- var big = thiis.parentElement.getAttribute("href")
- var orgim = document.getElementById("largeImage")
- orgim.setAttribute("src", big)
- }
- function normalImg(thiis){
- document.getElementById("largeImage").removeAttribute("src")
- }
- function filterManager(){
- //Load blacklist if already present
- if (JSON.parse(localStorage.getItem('blacklist'))){
- blacklist = JSON.parse(localStorage.getItem('blacklist'))
- if (!blacklist[board]){
- blacklist[board] = []
- }
- }
- }
- /* todo import/export filter list and prune expired threads*/
- /*
- function filterManager_new(){
- //Create Buttons
- var importBtn = document.createElement("BUTTON")
- importBtn.setAttribute("onclick", "importList()")
- var label = document.createTextNode("Import")
- importBtn.appendChild(label)
- document.getElementById("filterManager").appendChild(importBtn)
- var exportBtn = document.createElement("BUTTON")
- exportBtn.setAttribute("onclick", "exportList()")
- var label = document.createTextNode("Export")
- exportBtn.appendChild(label)
- document.getElementById("filterManager").appendChild(exportBtn)
- var pruneBtn = document.createElement("BUTTON")
- pruneBtn.setAttribute("onclick", "pruneList()")
- var label = document.createTextNode("Prune")
- pruneBtn.appendChild(label)
- document.getElementById("filterManager").appendChild(pruneBtn)
- //Load blacklist if already present
- if (JSON.parse(localStorage.getItem('blacklist'))){
- blacklist = JSON.parse(localStorage.getItem('blacklist'))
- if (!blacklist[board]){
- blacklist[board] = []
- }
- }
- }
- function importList(){}
- // 5input id="myInput" type="text" value="Swag" />
- //
- //5script>
- // var test = "test";
- // document.getElementById("myInput").value = test;
- //5script>
- function exportList(){
- var textToSave = JSON.stringify(blacklist)
- var hiddenElement = document.createElement('a')
- hiddenElement.href = 'data:attachment/text,' + encodeURI(textToSave)
- hiddenElement.target = '_blank'
- hiddenElement.download = 'myFile.txt'
- document.body.appendChild(hiddenElement)
- hiddenElement.click()
- document.body.removeChild(hiddenElement)
- }
- function pruneList() {
- var promise = new Promise(function(resolve, reject) {
- resolve(1);
- });
- promise.then(function(val) {
- console.log("dfdsfdsf");
- pruneListo()
- }).then(function(val) {
- console.log("mnmnmnmnmnm")
- commit() // 3
- })
- }
- function pruneList_old() {
- var a = function(){pruneListo()}
- var b = function(){commit()}
- var promise = pruneListo()
- promise.then(commit)
- .then(function (greeting) {
- console.log(greeting); // 'hello world!!!!’
- });
- }
- function pruneListo(callback) {
- //console.log(templist)
- //rewriteList(function(data) {
- fetch_json("https://8ch.net/" + board + "/threads.json", function(data) {
- for (var a of data) {
- fetch_json("https://8ch.net/" + board + "/" + a.page + ".json", function(data) {
- for (var a of data.threads) {
- if (blacklist[board].indexOf(a.posts[0].no) >= 0) {
- templist.push(a.posts[0].no)
- //console.log(a.posts[0].no)
- }
- }
- })
- }
- //callback()
- })
- //commit()
- }
- function commit (){console.log("fuck" + templist)}
- function rewriteList(x, callback) {
- //blacklist[board] = templist
- //console.log(templist)
- //console.log(blacklist)
- callback()
- }
- */
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement