Advertisement
Guest User

Untitled

a guest
May 23rd, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 22.99 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <link rel="shortcut icon" type="image/x-icon" href="http://localhost:8000/8ch/favicon.ico"/>
  6. <style>
  7. body {
  8. background:#EEF2FF;
  9. font:10pt arial,helvetica,sans-serif;
  10. }
  11.  
  12. .boardlist {
  13. background-color:#EEF2FF;
  14. position:fixed;
  15. width:100%;
  16. z-index:998;
  17. }
  18.  
  19. .spacer {
  20. width:100%;
  21. height:40px;
  22. }
  23.  
  24. .reply {
  25. background:#D6DAF0;
  26. display:inline-block;
  27. max-width:94%;
  28. border-color:#B7C5D9;
  29. border-style:none solid solid none;
  30. border-width:1px;
  31. margin:.2em 4px;
  32. padding:.5em .3em .5em .6em;
  33. }
  34.  
  35. .intro {
  36. clear:none;
  37. margin:.5em 0;
  38. padding:0 0 .2em;
  39. }
  40.  
  41. .zoom {
  42. pointer-events:none;
  43. }
  44.  
  45. .intro span.subject {
  46. color:#0F0C5D;
  47. font-weight:700;
  48. float:left;
  49. margin-right:1em;
  50. }
  51.  
  52. .intro span.name {
  53. color:#117743;
  54. font-weight:700;
  55. float:left;
  56. margin-right:1em;
  57. }
  58.  
  59. .fileinfo {
  60. display:block;
  61. position:relative;
  62. }
  63.  
  64. .file {
  65. margin-right:2px;
  66. float:left;
  67. position:relative;
  68. }
  69.  
  70. .post-imagexxx {
  71. clear:both;
  72. }
  73.  
  74. .img {
  75. clear:both;
  76. position:relative;
  77. width:100%;
  78. }
  79.  
  80. a,a:visited {
  81. color:#34345C;
  82. text-decoration:underline;
  83. }
  84.  
  85. a.post_no {
  86. text-decoration:none;
  87. margin:0;
  88. padding:0;
  89. }
  90.  
  91. .intro a.post_no {
  92. color:inherit;
  93. }
  94.  
  95. .intro a.post_no,p.intro a.email,p.intro a.post_anchor {
  96. margin:0;
  97. }
  98.  
  99. .file:not(.multifile) {
  100. float:none;
  101. }
  102.  
  103. .intro a {
  104. margin-left:5px;
  105. }
  106.  
  107. div.post p {
  108. display:block;
  109. font-size:13px;
  110. line-height:1.16em;
  111. min-height:1.16em;
  112. margin:0;
  113. }
  114.  
  115. div.post div.body {
  116. margin-top:.8em;
  117. padding-bottom:.3em;
  118. padding-right:3em;
  119. white-space:pre-wrap;
  120. word-wrap:break-word;
  121. clear:none;
  122. }
  123.  
  124. div.post.reply div.body {
  125. margin-left:1.8em;
  126. }
  127.  
  128. div.post.reply div.body a {
  129. color:#D00;
  130. }
  131.  
  132. .quote {
  133. color:#789922;
  134. }
  135.  
  136. span.heading {
  137. color:#AF0A0F;
  138. font-size:11pt;
  139. font-weight:700;
  140. }
  141.  
  142. span.spoiler {
  143. background:#000;
  144. color:#000;
  145. padding:0 1px;
  146. }
  147.  
  148. pre {
  149. display:block!important;
  150. font:9pt monospace;
  151. max-width:inherit;
  152. overflow:auto;
  153. word-wrap:normal;
  154. margin:0 display:inline!important;
  155. }
  156.  
  157. .intro,div.post div.body {
  158. clear:none;
  159. }
  160.  
  161. .ltr {
  162. direction:ltr;
  163. }
  164.  
  165. div.boardlist {
  166. color:#89A;
  167. font-size:9pt;
  168. margin-top:3px;
  169. }
  170.  
  171. div.boardlist a {
  172. text-decoration:none;
  173. }
  174.  
  175. div.post.reply {
  176. background:#D6DAF0;
  177. display:inline-block;
  178. max-width:94%!important;
  179. border-color:#B7C5D9;
  180. border-style:none solid solid none;
  181. border-width:1px;
  182. margin:.2em 4px;
  183. padding:.5em .3em .5em .6em;
  184. }
  185.  
  186. #largeImage {
  187. position:fixed;
  188. top:0;
  189. right:0;
  190. max-height:100%;
  191. z-index:999;
  192. }
  193.  
  194. .thread div.files div.file,.body,.thread div.op div.files div.file,.file,.body {
  195. float:left;
  196. position:relative;
  197. }
  198.  
  199. .intro span.hide,.intro span.time,.intro span.hide,.intro span.time {
  200. float:left;
  201. margin-right:1em;
  202. }
  203.  
  204. .thread div.post,.thread div.op,.post,.op,.post,.thread div.op,.thread div.post,.op,.post,.thread div.op,.thread div.post {
  205. float:left;
  206. position:relative;
  207. width:100%;
  208. }
  209. </style>
  210. <base href="https://8ch.net/">
  211. </head>
  212. <body>
  213. <div class="boardlist">
  214. <span class="favorite-boards"> [
  215. <a href="http://8ch.net/index.html"><i class="fa fa-home" title="Home"></i>home</a> ]
  216. [
  217. <a href="" id="v" onclick='setThroughLink(this); return false;'>v</a> /
  218. <a href="" id="tech" onclick='setThroughLink(this); return false;'>tech</a> /
  219. <a href="" id="agdg" onclick='setThroughLink(this); return false;'>agdg</a> /
  220. <a href="" id="robowaifu" onclick='setThroughLink(this); return false;'>robowaifu</a> /
  221. <a href="" id="hydrus" onclick='setThroughLink(this); return false;'>hydrus</a> ]
  222. [
  223. <a href="" id="f" onclick='setThroughLink(this); return false;'>f</a> /
  224. <a href="" id="hgg" onclick='setThroughLink(this); return false;'>hgg</a> /
  225. <a href="" id="htg" onclick='setThroughLink(this); return false;'>htg</a> /
  226. <a href="" id="b" onclick='setThroughLink(this); return false;'>b</a> /
  227. <a href="" id="pol" onclick='setThroughLink(this); return false;'>pol</a> /
  228. <a href="" id="3d" onclick='setThroughLink(this); return false;'>3d</a> /
  229. <a href="" id="delicious" onclick='setThroughLink(this); return false;'>delicious</a> /
  230. <a href="" id="liru" onclick='setThroughLink(this); return false;'>liru</a> ]
  231. </span>
  232. <span id="filterManager">
  233. </span>
  234. </div>
  235.  
  236. <div class="zoom">
  237. <img id="largeImage" src="" />
  238. </div>
  239.  
  240. <div class="spacer">&nbsp;</div>
  241. </body>
  242.  
  243. <script>
  244.  
  245. var board
  246. var templist = []
  247. var blacklist = {}
  248.  
  249.  
  250. function setThroughLink(yourLink){
  251. removeDummy()
  252. board = yourLink.id
  253. console.log("current board: " + board)
  254. blacklist[board] = []
  255. filterManager()
  256. console.log("showing filter array")
  257. console.log(blacklist)
  258. start()
  259. }
  260.  
  261.  
  262. function removeDummy(){
  263. console.log("clearing screen")
  264. var elem = document.getElementsByClassName("thread")
  265. //console.log(elem)
  266.  
  267. while (elem[0]){
  268. elem[0].remove()
  269. }
  270.  
  271. return false;
  272. }
  273.  
  274.  
  275. async function start(){
  276. let urls = await get_url_list(board)
  277. let pages_json = await fetch_all_urls(urls)
  278. let thread_list = await filter_and_bump_order_threads(pages_json)
  279.  
  280. //console.log(thread_list)
  281. console.log("all pages parsed")
  282.  
  283. let keys = await Object.keys(thread_list)
  284. for (i = keys.length - 1; i >= 0; i--) {
  285. display_thread(thread_list[keys[i]])
  286. }
  287. }
  288.  
  289. async function get_url_list(board){
  290. let response = await fetch("https://8ch.net/" + board + "/threads.json")
  291. let board_data = await response.json()
  292.  
  293. let pages = board_data.length
  294. let urls = []
  295. for (i = 0; i < pages; i++){
  296. urls.push("https://8ch.net/" + board + "/" + i + ".json")
  297. }
  298. return urls
  299. }
  300.  
  301. async function fetch_all_urls(urls){
  302. try{
  303. var data = await Promise.all(urls.map(url =>fetch(url).then((response) => response.json())))
  304. return (data)
  305. }
  306. catch (error) {
  307. console.log(error)
  308. throw (error)
  309. }
  310. }
  311.  
  312. async function filter_and_bump_order_threads(pages_json){
  313. let bump_order = {}
  314. let pages = pages_json.length
  315. for (i = 0; i < pages; i++){
  316. //console.log(pages_json[i].threads)
  317. for (var a of pages_json[i].threads) {
  318. if (!(blacklist[board].indexOf(a.posts[0].no) >= 0)) { /*if thread is NOT in blacklist array add it*/
  319. bump_order[a.posts[a.posts.length-1].last_modified] = a.posts
  320. }
  321. }
  322. }
  323. //console.log(bump_order)
  324. return bump_order
  325. }
  326.  
  327. async function display_thread(thread){
  328. var is_op = true
  329. for(post of thread){
  330. if (is_op){
  331. var no = post.no
  332. var com = post.com
  333. var filename = post.filename
  334. var ext = post.ext
  335. var tim = post.tim
  336. var fsize = post.fsize
  337. var name = post.name
  338. var w = post.w
  339. var h = post.h
  340. var tn_w = post.tn_w
  341. var tn_h = post.tn_h
  342. var sub = post.sub
  343. if (sub == null){sub=""}
  344. var time = post.time
  345.  
  346. threadidop = "thread_" + no
  347. var hh = "hide_" + no
  348.  
  349. var imagelink = "https://media.8ch.net/file_store/" + tim + ext
  350.  
  351. //replies
  352. var newDiv = document.createElement("div")
  353.  
  354. newDiv.setAttribute("class", "thread")
  355. newDiv.setAttribute("id", "thread_" + no)
  356. newDiv.setAttribute("data-board", board)
  357.  
  358. if (blacklist[board].indexOf(no) >= 0){
  359. newDiv.setAttribute("style", "display: none")
  360. }
  361.  
  362. var elements = newDiv.childNodes
  363.  
  364. var op = document.createElement("div")
  365. op.setAttribute("class", "op")
  366. var intro = document.createElement("div")
  367. intro.setAttribute("class", "intro")
  368. var hid = document.createElement("BUTTON")
  369. hid.setAttribute("onclick", "hide_thread(" + no + ")")
  370. var t = document.createTextNode("Hide")
  371. hid.appendChild(t)
  372. var hide = document.createElement("span")
  373. hide.setAttribute("class", "hide")
  374. hide.appendChild(hid)
  375. intro.appendChild(hide)
  376. var subject = document.createElement("span")
  377. subject.setAttribute("class", "subject")
  378. subject.innerHTML = sub
  379. intro.appendChild(subject)
  380. var name = document.createElement("span")
  381. name.setAttribute("class", "name")
  382. name.innerHTML = post.name
  383. intro.appendChild(name)
  384. var time = document.createElement("span")
  385. time.setAttribute("class", "time")
  386. time.innerHTML = timeAgoFromEpochTime(post.time)
  387. intro.appendChild(time)
  388. var post_no = document.createElement("a")
  389. post_no.setAttribute("class", "post_no")
  390. post_no.setAttribute("href", "http://8ch.net/" + board + "/res/" + no + ".html")
  391. post_no.innerHTML = post.no
  392. intro.appendChild(post_no)
  393. op.appendChild(intro)
  394.  
  395. /////////////////////////////////////////////////////////////////////////////////////////
  396. create_post(op, post)
  397. /////////////////////////////////////////////////////////////////////////////////////////
  398.  
  399. newDiv.appendChild(op)
  400.  
  401. document.body.appendChild(newDiv)
  402.  
  403. is_op = false
  404. }
  405.  
  406. else{
  407. var no = post.no
  408. var com = post.com
  409. var name = post.name
  410. var time = post.time
  411.  
  412. //replies
  413.  
  414. var newDiv = document.createElement("div")
  415. newDiv.setAttribute("class", "post reply")
  416. newDiv.setAttribute("id", "reply_" + no)
  417.  
  418. var intro = document.createElement("div")
  419. intro.setAttribute("class", "intro")
  420.  
  421. var name = document.createElement("span")
  422. name.setAttribute("class", "name")
  423. name.innerHTML = post.name
  424. intro.appendChild(name)
  425.  
  426. var time = document.createElement("span")
  427. time.setAttribute("class", "time")
  428. time.innerHTML = timeAgoFromEpochTime(post.time)
  429. intro.appendChild(time)
  430.  
  431. intro.appendChild(document.createElement("span")).innerHTML = no
  432. newDiv.appendChild(intro)
  433.  
  434. create_post(newDiv,post)
  435.  
  436. document.getElementById(threadidop).appendChild(newDiv)
  437. }
  438. }
  439. }
  440.  
  441. function hide_thread(n){
  442. blacklist[board].push(n)
  443. localStorage.setItem("blacklist", JSON.stringify(blacklist))
  444.  
  445. var hideDiv = document.getElementById("thread_" + n)
  446. hideDiv.setAttribute("style", "display: none")
  447. }
  448.  
  449. function create_post(parent, array){
  450.  
  451. //thread/op-reply/intro-files-body (function does files and body to parent op or post reply)
  452.  
  453. if (!(array.filename == null)) { //if at least a image is present
  454. var files = document.createElement("div")
  455. files.setAttribute("class", "files")
  456.  
  457. create_file(files, array) //do image
  458.  
  459. if (!(array.extra_files == null)){ //if extra images present
  460. for (var i of array.extra_files){
  461. create_file(files, i)
  462. }
  463. }
  464.  
  465. parent.appendChild(files)
  466. }
  467.  
  468. var body = document.createElement("div")
  469. body.setAttribute("class", "body")
  470. body.innerHTML = array.com
  471. parent.appendChild(body)
  472.  
  473. }
  474.  
  475. function create_file(parent, array){
  476. var file = document.createElement("div")
  477. file.setAttribute("class", "file")
  478. var fileinfo = document.createElement("span")
  479. fileinfo.setAttribute("class", "fileinfo")
  480.  
  481. var trunc = array.filename
  482. if (trunc.length > 26){
  483. trunc = trunc.substring(0,24)+"…"
  484. }
  485.  
  486. var imageOriginal = "https://media.8ch.net/file_store/" + array.tim + array.ext + "/" + trunc + array.ext
  487. var imageHashed = "https://media.8ch.net/file_store/" + array.tim + array.ext
  488. var imageThumbnail = "https://media.8ch.net/file_store/thumb/" + array.tim + array.ext
  489.  
  490. if (array.ext == ".webm" || array.ext == ".mp4"){
  491. imageThumbnail = "https://media.8ch.net/file_store/thumb/" + array.tim + ".jpg"
  492. }
  493.  
  494. //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>"
  495.  
  496. var span1 = document.createElement("span")
  497. span1.innerHTML = "File : "
  498. var linktoimage = document.createElement("a")
  499. //linktoimage.setAttribute("title", array.filename)
  500. linktoimage.setAttribute("href", imageOriginal)
  501. linktoimage.setAttribute("download", "ffff")
  502. linktoimage.innerHTML = trunc + array.ext
  503. var span2 = document.createElement("span")
  504. span2.innerHTML = " (" + array.fsize + ", " + array.w + "x" + array.h + ")"
  505. fileinfo.appendChild(span1)
  506. fileinfo.appendChild(linktoimage)
  507. fileinfo.appendChild(span2)
  508. file.appendChild(fileinfo)
  509.  
  510. var image = document.createElement("a")
  511.  
  512. var imagelink = "https://media.8ch.net/file_store/thumb/" + array.tim + array.ext
  513.  
  514.  
  515. image.setAttribute("href", imageOriginal)
  516. image.setAttribute("class", "img")
  517. image.setAttribute("id", "img")
  518. 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\">"
  519. file.appendChild(image)
  520.  
  521. parent.appendChild(file)
  522. }
  523.  
  524. function timeAgoFromEpochTime(epoch) {
  525. var secs = ((new Date()).getTime() / 1000) - epoch;
  526. Math.floor(secs);
  527. var minutes = secs / 60;
  528. secs = Math.floor(secs % 60);
  529. if (minutes < 1) {
  530. return secs + (secs > 1 ? ' seconds ago' : ' second ago');
  531. }
  532. var hours = minutes / 60;
  533. minutes = Math.floor(minutes % 60);
  534. if (hours < 1) {
  535. return minutes + (minutes > 1 ? ' minutes ago' : ' minute ago');
  536. }
  537. var days = hours / 24;
  538. hours = Math.floor(hours % 24);
  539. if (days < 1) {
  540. return hours + (hours > 1 ? ' hours ago' : ' hour ago');
  541. }
  542. var weeks = days / 7;
  543. days = Math.floor(days % 7);
  544. if (weeks < 1) {
  545. return days + (days > 1 ? ' days ago' : ' day ago');
  546. }
  547. var months = weeks / 4.35;
  548. weeks = Math.floor(weeks % 4.35);
  549. if (months < 1) {
  550. return weeks + (weeks > 1 ? ' weeks ago' : ' week ago');
  551. }
  552. var years = months / 12;
  553. months = Math.floor(months % 12);
  554. if (years < 1) {
  555. return months + (months > 1 ? ' months ago' : ' month ago');
  556. }
  557. years = Math.floor(years);
  558. return years + (years > 1 ? ' years ago' : ' years ago');
  559. }
  560.  
  561. function bigImg(thiis){
  562.  
  563. console.log(thiis.parentElement)
  564. console.log(thiis.parentElement.getAttribute("href"))
  565.  
  566. var big = thiis.parentElement.getAttribute("href")
  567. var orgim = document.getElementById("largeImage")
  568. orgim.setAttribute("src", big)
  569. }
  570.  
  571. function normalImg(thiis){
  572. document.getElementById("largeImage").removeAttribute("src")
  573. }
  574.  
  575. function filterManager(){
  576.  
  577. //Load blacklist if already present
  578.  
  579. if (JSON.parse(localStorage.getItem('blacklist'))){
  580. blacklist = JSON.parse(localStorage.getItem('blacklist'))
  581.  
  582. if (!blacklist[board]){
  583. blacklist[board] = []
  584. }
  585. }
  586. }
  587.  
  588.  
  589. /* todo import/export filter list and prune expired threads*/
  590.  
  591. /*
  592.  
  593. function filterManager_new(){
  594.  
  595. //Create Buttons
  596.  
  597. var importBtn = document.createElement("BUTTON")
  598. importBtn.setAttribute("onclick", "importList()")
  599. var label = document.createTextNode("Import")
  600. importBtn.appendChild(label)
  601.  
  602. document.getElementById("filterManager").appendChild(importBtn)
  603.  
  604. var exportBtn = document.createElement("BUTTON")
  605. exportBtn.setAttribute("onclick", "exportList()")
  606. var label = document.createTextNode("Export")
  607. exportBtn.appendChild(label)
  608.  
  609. document.getElementById("filterManager").appendChild(exportBtn)
  610.  
  611. var pruneBtn = document.createElement("BUTTON")
  612. pruneBtn.setAttribute("onclick", "pruneList()")
  613. var label = document.createTextNode("Prune")
  614. pruneBtn.appendChild(label)
  615.  
  616.  
  617. document.getElementById("filterManager").appendChild(pruneBtn)
  618.  
  619. //Load blacklist if already present
  620. if (JSON.parse(localStorage.getItem('blacklist'))){
  621. blacklist = JSON.parse(localStorage.getItem('blacklist'))
  622.  
  623. if (!blacklist[board]){
  624. blacklist[board] = []
  625. }
  626. }
  627. }
  628.  
  629. function importList(){}
  630.  
  631. // 5input id="myInput" type="text" value="Swag" />
  632. //
  633. //5script>
  634. // var test = "test";
  635. // document.getElementById("myInput").value = test;
  636. //5script>
  637.  
  638. function exportList(){
  639. var textToSave = JSON.stringify(blacklist)
  640. var hiddenElement = document.createElement('a')
  641. hiddenElement.href = 'data:attachment/text,' + encodeURI(textToSave)
  642. hiddenElement.target = '_blank'
  643. hiddenElement.download = 'myFile.txt'
  644. document.body.appendChild(hiddenElement)
  645. hiddenElement.click()
  646. document.body.removeChild(hiddenElement)
  647. }
  648.  
  649. function pruneList() {
  650.  
  651. var promise = new Promise(function(resolve, reject) {
  652. resolve(1);
  653. });
  654.  
  655. promise.then(function(val) {
  656. console.log("dfdsfdsf");
  657. pruneListo()
  658. }).then(function(val) {
  659. console.log("mnmnmnmnmnm")
  660. commit() // 3
  661. })
  662.  
  663. }
  664.  
  665. function pruneList_old() {
  666.  
  667.  
  668. var a = function(){pruneListo()}
  669. var b = function(){commit()}
  670.  
  671. var promise = pruneListo()
  672. promise.then(commit)
  673. .then(function (greeting) {
  674. console.log(greeting); // 'hello world!!!!’
  675. });
  676. }
  677.  
  678. function pruneListo(callback) {
  679.  
  680. //console.log(templist)
  681.  
  682. //rewriteList(function(data) {
  683.  
  684. fetch_json("https://8ch.net/" + board + "/threads.json", function(data) {
  685.  
  686.  
  687.  
  688. for (var a of data) {
  689. fetch_json("https://8ch.net/" + board + "/" + a.page + ".json", function(data) {
  690. for (var a of data.threads) {
  691. if (blacklist[board].indexOf(a.posts[0].no) >= 0) {
  692.  
  693.  
  694.  
  695. templist.push(a.posts[0].no)
  696. //console.log(a.posts[0].no)
  697. }
  698. }
  699. })
  700.  
  701.  
  702.  
  703. }
  704.  
  705. //callback()
  706.  
  707.  
  708.  
  709. })
  710.  
  711. //commit()
  712.  
  713. }
  714.  
  715. function commit (){console.log("fuck" + templist)}
  716.  
  717. function rewriteList(x, callback) {
  718. //blacklist[board] = templist
  719. //console.log(templist)
  720. //console.log(blacklist)
  721. callback()
  722. }
  723.  
  724. */
  725.  
  726. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement