Sleazy Fork is available in English.

HV - Clean Forum Contents

E-H Forums Tweaks

As of 2016-02-05. See the latest version.

  1. // ==UserScript==
  2. // @name HV - Clean Forum Contents
  3. // @grant none
  4. // @include /^https?://forums\.e-hentai\.org\/index\.php\?.*\bshowtopic=.*/
  5. // @include /^https?://forums\.e-hentai\.org/index\.php\?.*\bresult_type=posts/
  6. // @include /^https?://forums\.e-hentai\.org\/index\.php\?act=([Pp]ost|ST|Msg)&/
  7. // @include /^https?://forums\.e-hentai\.org\/index\.php\?showuser=.*/
  8. // @include /^https?://forums\.e-hentai\.org\/index\.php\?showforum=.*/
  9. // @include http://hentaiverse.org/?s=Bazaar&ss=mm*
  10. // @version 0.0.1.20160205083229
  11. // @namespace https://greasyfork.org/users/2233
  12. // @description E-H Forums Tweaks
  13. // ==/UserScript==
  14.  
  15. var wnd = window
  16. var doc = wnd.document
  17. var loc = wnd.location
  18. var href = loc.href
  19.  
  20. var $ = function(e, css) { if(!css) { css=e; e=doc }; return e.querySelector(css) }
  21. var $$ = function(e, css) { if(!css) { css=e; e=doc }; return e.querySelectorAll(css) }
  22.  
  23. /*** Settings ***/
  24.  
  25. // For forums
  26. var hide_pinned_threads = true
  27. var hide_unread_imgs = true
  28. var hide_closed_shops = true
  29. var highlight_auctions = true
  30. var highlight_shop_owners = true
  31. var hide_top_area = true
  32. var hide_bottom_area = true
  33. var hide_last_posts = true
  34. if(typeof wnd.do_not_hide == 'undefined') {
  35. var do_not_hide = [ // user IDs
  36. 0,
  37. ]
  38. } else { var do_not_hide = wnd.do_not_hide }
  39. if(typeof wnd.wts_shop_owners_to_highlight == 'undefined') {
  40. var wts_shop_owners_to_highlight = [ // user IDs
  41. 0,
  42. ]
  43. } else { var wts_shop_owners_to_highlight = wnd.wts_shop_owners_to_highlight }
  44. if(typeof wnd.wtb_shop_owners_to_highlight == 'undefined') {
  45. var wtb_shop_owners_to_highlight = [ // user IDs
  46. 0,
  47. ]
  48. } else { var wtb_shop_owners_to_highlight = wnd.wtb_shop_owners_to_highlight }
  49. if(typeof wnd.wts_thread_blist == 'undefined') {
  50. var wts_thread_blist = [ // thread IDs
  51. 0,
  52. ]
  53. } else { var wts_thread_blist = wnd.wts_thread_blist }
  54. if(typeof wnd.wtb_thread_blist == 'undefined') {
  55. var wtb_thread_blist = [ // thread IDs
  56. 0,
  57. ]
  58. } else { var wtb_thread_blist = wnd.wtb_thread_blist }
  59. if(typeof wnd.chat_thread_wlist == 'undefined') {
  60. var chat_thread_wlist = [ // thread IDs
  61. 0,
  62. ]
  63. } else { var chat_thread_wlist = wnd.chat_thread_wlist }
  64. if(typeof wnd.user_blist == 'undefined') {
  65. var user_blist = [ // user IDs
  66. 0,
  67. ]
  68. } else { var user_blist = wnd.user_blist }
  69. if(typeof wnd.user_blist_wts == 'undefined') {
  70. var user_blist_wts = [ // user IDs
  71. 0,
  72. ]
  73. } else { var user_blist_wts = wnd.user_blist_wts }
  74. if(typeof wnd.user_blist_wtb == 'undefined') {
  75. var user_blist_wtb = [ // user IDs
  76. 0,
  77. ]
  78. } else { var user_blist_wtb = wnd.user_blist_wtb }
  79. if(typeof wnd.uname_blist == 'undefined') {
  80. var uname_blist = [ // hide quotes by username (string)
  81. '',
  82. ]
  83. } else { var uname_blist = wnd.uname_blist }
  84.  
  85. // For posts
  86. var hide_emotes = [
  87. /\bstyle_emoticons\//,
  88. /\/folder_post_icons\//,
  89. /\/ehgt\/cm\//,
  90. ]
  91. var hide_cutie_marks = true
  92. var hide_post_count = true
  93. var hide_warn_levels = true
  94. var dup_edit_time = true
  95. if(typeof wnd.uid_blist == 'undefined') {
  96. var uid_blist = [ // hide posts by uid (integer)
  97. 0,
  98. ]
  99. } else { var uid_blist = wnd.uid_blist }
  100. if(typeof wnd.dont_clean == 'undefined') {
  101. var dont_clean = [ // topic id
  102. 0,
  103. ]
  104. } else { var dont_clean = wnd.dont_clean }
  105.  
  106. /*** End of Settings ***/
  107.  
  108. /*** The BWList script ***/
  109.  
  110. var showforum = href.match(/showforum=(\d+)/)
  111. if(!showforum) { showforum = href.match(/&?\bf=(\d+)/) }
  112. if(showforum) {
  113. showforum = showforum[1]
  114.  
  115. // Hide unread imgs
  116. if(hide_unread_imgs) {
  117. var imgs = $$('img[src="style_images/ambience/newpost.gif"]')
  118. for(var i=0, len=imgs.length; i<len; i++) { imgs[i].style.display = 'none' }
  119. var imgs = $$('img[src="style_images/fusion/newpost.gif"]')
  120. for(var i=0, len=imgs.length; i<len; i++) { imgs[i].style.display = 'none' }
  121. }
  122.  
  123. // Hide closed shops
  124. if(hide_closed_shops) {
  125. if(showforum == '77' || showforum == '78') {
  126. var lnks = $$('td.row1 > div > span > a[id^="tid-link-"]')
  127. //var closed_patterns = /\b(close|closed|complete|(delete|del\b)|done|end|none|nothing|shut|sorry)/i
  128. var closed_patterns = /\b(close|closed|complete|(delete|del\b)|done|end|none|nothing|shut|sorry|auction|lottery|lotto)/i
  129. for(var i=0, len=lnks.length; i<len; i++) {
  130. if((!/&st=/.test(href)) || (/&st=0/.test(href))) { // (probably) on the first page
  131. if(/\b(auction|lottery|lotto)\b/i.test(lnks[i].textContent)) { continue }
  132. }
  133. var owner = $(lnks[i].parentNode.parentNode.parentNode.parentNode, 'td.row2 > a[href*="showuser"]')
  134. if(do_not_hide.indexOf(parseInt(owner.href.match(/showuser=(\d+)/)[1])) != -1){ continue }
  135. if(closed_patterns.test(lnks[i].textContent)) {
  136. lnks[i].parentNode.parentNode.parentNode.parentNode.style.display = 'none'
  137. continue
  138. }
  139. var desc = $(lnks[i].parentNode.parentNode, 'span#tid-desc-'+lnks[i].id.match(/(\d+)/)[1])
  140. if(closed_patterns.test(desc.textContent)) {
  141. desc.parentNode.parentNode.parentNode.parentNode.style.display = 'none'
  142. continue
  143. }
  144. }
  145. }
  146. }
  147.  
  148. // Highlight auctions
  149. if(highlight_auctions) {
  150. if(showforum == '77') {
  151. var lnks = $$('td.row1 > div > span > a[id^="tid-link-"]')
  152. for(var i=0, len=lnks.length; i<len; i++) {
  153. if(/\b(auction|lottery|lotto)\b/i.test(lnks[i].textContent)) {
  154. var owner = $(lnks[i].parentNode.parentNode.parentNode.parentNode, 'td.row2 > a[href*="showuser"]')
  155. if(owner.style.color == '') { owner.style.color = 'blue'}
  156. }
  157. }
  158. }
  159. }
  160.  
  161. // Highlight shop owners
  162. if(highlight_shop_owners) {
  163. var fav = []
  164. if(showforum == '77') { fav = wts_shop_owners_to_highlight } // WTS
  165. else if(showforum == '78') { fav = wtb_shop_owners_to_highlight } // WTB
  166. var owner = $$('td.row2 > a[href*="showuser"]')
  167. for(var i=0, len=owner.length; i<len; i++) {
  168. //if((fav.indexOf(owner[i].textContent) != -1) && (owner[i].style.color == '')) { owner[i].style.color = 'red' }
  169. for(var j=0, len_j=fav.length; j<len_j; j++) {
  170. if((new RegExp('showuser='+fav[j]+'\\b').test(owner[i].href)) && (owner[i].style.color == '')) {
  171. owner[i].style.color = 'red'
  172. break
  173. }
  174. }
  175. }
  176. }
  177.  
  178. // Hide specified forum threads
  179. var thread_blist = thread_wlist = []
  180. if(showforum == '76') { thread_wlist = chat_thread_wlist } // Chat
  181. else if(showforum == '77') { thread_blist = wts_thread_blist } // WTS
  182. else if(showforum == '78') { thread_blist = wtb_thread_blist } // WTB
  183. if(thread_blist.length) {
  184. for(var i=0, len=thread_blist.length; i<len; i++) {
  185. try { $('#tid-link-'+thread_blist[i]).parentNode.parentNode.parentNode.parentNode.style.display = 'none' } catch(e) {}
  186. }
  187. }
  188. else if(thread_wlist.length) {
  189. var lnks = $$('td.row1 > div > span > a[id^="tid-link-"]')
  190. for(var i=0, len=lnks.length; i<len; i++) {
  191. if(!/^tid-link-/.test(lnks[i].id)) { continue }
  192. var tid = parseInt(lnks[i].id.match(/tid-link-(\d+)/)[1])
  193. if(thread_wlist.indexOf(tid)==-1) {
  194. try { lnks[i].parentNode.parentNode.parentNode.parentNode.style.display = 'none' } catch(e) {}
  195. }
  196. }
  197. }
  198.  
  199. // Hide threads made by specific users on any subforums
  200. if(user_blist.length) {
  201. var users = $$('td.row2 > a[href*="showuser"]')
  202. for(var i=0, len=users.length; i<len; i++) {
  203. for(var j=0, len_j=user_blist.length; j<len_j; j++) {
  204. //if((new RegExp('showuser='+user_blist[j]+'\\b').test(users[i].href)) && (users[i].style.color == '')) {
  205. if(new RegExp('showuser='+user_blist[j]+'\\b').test(users[i].href)) {
  206. //if(!/\bauction\b/i.test(users[i].parentNode.parentNode.querySelectorAll('.row1')[2].textContent)) {
  207. //users[i].parentNode.parentNode.style.display = 'none'
  208. //}
  209. users[i].parentNode.parentNode.style.display = 'none'
  210. break
  211. }
  212. }
  213. }
  214. }
  215.  
  216. // Hide threads made by specific users on WTS
  217. if(user_blist_wts.length) {
  218. if(showforum == '77') {
  219. var users = $$('td.row2 > a[href*="showuser"]')
  220. for(var i=0, len=users.length; i<len; i++) {
  221. for(var j=0, len_j=user_blist_wts.length; j<len_j; j++) {
  222. //if((new RegExp('showuser='+user_blist_wts[j]+'\\b').test(users[i].href)) && (users[i].style.color == '')) {
  223. if(new RegExp('showuser='+user_blist_wts[j]+'\\b').test(users[i].href)) {
  224. if(!/\bauction\b/i.test(users[i].parentNode.parentNode.querySelectorAll('.row1')[2].textContent)) {
  225. users[i].parentNode.parentNode.style.display = 'none'
  226. }
  227. break
  228. }
  229. }
  230. }
  231. }
  232. }
  233.  
  234. // Hide threads made by specific users on WTB
  235. if(user_blist_wtb.length) {
  236. if(showforum == '78') {
  237. var users = $$('td.row2 > a[href*="showuser"]')
  238. for(var i=0, len=users.length; i<len; i++) {
  239. for(var j=0, len_j=user_blist_wtb.length; j<len_j; j++) {
  240. //if((new RegExp('showuser='+user_blist_wtb[j]+'\\b').test(users[i].href)) && (users[i].style.color == '')) {
  241. if(new RegExp('showuser='+user_blist_wtb[j]+'\\b').test(users[i].href)) {
  242. if(!/\bauction\b/i.test(users[i].parentNode.parentNode.querySelectorAll('.row1')[2].textContent)) {
  243. users[i].parentNode.parentNode.style.display = 'none'
  244. }
  245. break
  246. }
  247. }
  248. }
  249. }
  250. }
  251. }
  252.  
  253. /*** End of the BWList script ***/
  254.  
  255. if(/act=post/i.test(href)) {
  256. var ids = $$('.row2:first-child')
  257. for(var i=0, len=ids.length; i<len; i++) {
  258. if(uname_blist.indexOf(ids[i].textContent) != -1) {
  259. ids[i].parentNode.style.display = 'none'
  260. try { ids[i].parentNode.nextSibling.style.display = 'none' } catch(e) {}
  261. try { ids[i].parentNode.nextSibling.nextSibling.style.display = 'none' } catch(e) {}
  262. }
  263. }
  264. }
  265. else if(/:\/\/forums\./.test(href)) {
  266. if(/(showtopic=\d+)|(\bresult_type=posts)/.test(href)) {
  267. // Hide posts
  268. var hide_this = true
  269. if(/showtopic=\d+/.test(href) && (dont_clean.indexOf(parseInt(href.match(/showtopic=(\d+)/)[1])) != -1)) { hide_this = false }
  270. if(hide_this) {
  271. var borderwrap = $$('.borderwrap')
  272. for(var i=0, len=borderwrap.length; i<len; i++) {
  273. var is_post = ($(borderwrap[i], '.postcolor') != null)
  274. if(is_post) {
  275. var uid = $(borderwrap[i], 'a[href^="http://forums.e-hentai.org/index.php?showuser="], a[href^="https://forums.e-hentai.org/index.php?showuser="]')
  276. if(uid) {
  277. uid = parseInt(uid.href.match(/\?showuser=(\d+)/)[1])
  278. if(uid_blist.indexOf(uid) != -1) {
  279. borderwrap[i].style.display = 'none'
  280. try {
  281. if(/(BR|TABLE)/.test(borderwrap[i].previousSibling.previousSibling.tagName)) {
  282. borderwrap[i].previousSibling.previousSibling.style.display = 'none'
  283. }
  284. } catch(e) {}
  285. try {
  286. if(borderwrap[i].previousSibling.previousSibling.previousSibling.tagName == 'BR') {
  287. borderwrap[i].previousSibling.previousSibling.previousSibling.style.display = 'none'
  288. }
  289. } catch(e) {}
  290. try {
  291. if(/(BR|TABLE)/.test(borderwrap[i].nextSibling.nextSibling.tagName)) {
  292. borderwrap[i].nextSibling.nextSibling.style.display = 'none'
  293. }
  294. } catch(e) {}
  295. try {
  296. if(borderwrap[i].nextSibling.nextSibling.nextSibling.tagName == 'BR') {
  297. borderwrap[i].nextSibling.nextSibling.nextSibling.style.display = 'none'
  298. }
  299. } catch(e) {}
  300. }
  301. }
  302. }
  303. }
  304. }
  305. }
  306. else if(/showforum=\d+/.test(href)) {
  307. if(hide_pinned_threads) {
  308. var divs = document.querySelectorAll('tr>td.row1>div')
  309. if(divs) {
  310. for(var i=divs.length-1; i>=0; i--) { if(/Pinned:/.test(divs[i].textContent)) { divs[i].parentNode.parentNode.style.display = 'none' } }
  311. }
  312. }
  313. }
  314. }
  315. else if(/&ss=mm$/.test(href) || /&filter=inbox/.test(href)) {
  316. var letters = $$('#mainpane tr[onclick]')
  317. for(var i=0, len=letters.length; i<len; i++) {
  318. if(uname_blist.indexOf(letters[i].querySelector('td').textContent) != -1) {
  319. letters[i].style.display = 'none'
  320. }
  321. }
  322. }
  323.  
  324. // Hide quotes
  325. if(/:\/\/forums\./.test(href)) {
  326. var p = new RegExp('^QUOTE\\((' + uname_blist.join('|') + ') @', 'i')
  327. var postcolor = $$('.postcolor')
  328. for(var i=0, len=postcolor.length; i<len; i++) {
  329. var quotetop = $$(postcolor[i], '.quotetop')
  330. for(var j=0, len2=quotetop.length; j<len2; j++) {
  331. if(p.test(quotetop[j].textContent)) {
  332. quotetop[j].style.display = 'none'
  333. try { quotetop[j].nextSibling.style.display = 'none' } catch(e) {}
  334. try { if(quotetop[j].nextSibling.nextSibling.tagName == 'BR') { quotetop[j].nextSibling.nextSibling.style.display = 'none' } } catch(e) {}
  335. try { if(quotetop[j].nextSibling.nextSibling.nextSibling.tagName == 'BR') { quotetop[j].nextSibling.nextSibling.nextSibling.style.display = 'none' } } catch(e) {}
  336. try { if(quotetop[j].nextSibling.nextSibling.nextSibling.nextSibling.tagName == 'BR') { quotetop[j].nextSibling.nextSibling.nextSibling.nextSibling.style.display = 'none' } } catch(e) {}
  337. try { if(quotetop[j].nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.tagName == 'BR') { quotetop[j].nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.style.display = 'none' } } catch(e) {}
  338. }
  339. }
  340. }
  341. }
  342.  
  343. // Hide emotes
  344. if(hide_emotes.length >= 1) {
  345. var imgs = $$('IMG')
  346. for(var i=imgs.length-1; i>=0; i--) {
  347. for(var a=0, len=hide_emotes.length; a<len; a++) {
  348. if(hide_emotes[a].test(imgs[i].src)) {
  349. imgs[i].style.display = 'none'
  350. break
  351. }
  352. }
  353. }
  354. }
  355.  
  356. // Hide cutie marks
  357. if(hide_cutie_marks) {
  358. if(/:\/\/forums\./.test(href)) {
  359. var div = $$('DIV[style*="url(http://forums.e-hentai.org/ehgt/cm/"], DIV[style*="url(https://forums.e-hentai.org/ehgt/cm/"]')
  360. for(var i=0, len=div.length; i<len; i++) { div[i].style.display = 'none' }
  361. }
  362. }
  363.  
  364. // Hide post counts
  365. if(hide_post_count) {
  366. if(/:\/\/forums\./.test(href)) {
  367. var a = $$('a[onclick^="link_to_post("]')
  368. for(var i=0, len=a.length; i<len; i++) { a[i].text = '#' }
  369. }
  370. }
  371.  
  372. // Hide warn levels
  373. if(hide_warn_levels) {
  374. if(/:\/\/forums\./.test(href)) {
  375. var w = $$('img[src*="style_images/ambience/warn"]')
  376. for(var i=0, len=w.length; i<len; i++) {
  377. w[i].style.display = 'none'
  378. try { w[i].previousSibling.textContent = '' } catch(e) {}
  379. try { w[i].previousSibling.previousSibling.textContent = '' } catch(e) {}
  380. try { w[i].previousSibling.previousSibling.previousSibling.textContent = '' } catch(e) {}
  381. try {
  382. var spacer = w[i].parentNode.parentNode.querySelectorAll('img[src*="style_images/ambience/spacer."]')
  383. for(var j=0, len2=spacer.length; j<len2; j++) {
  384. spacer[j].style.display = 'none'
  385. }
  386. } catch(e) {}
  387. }
  388. }
  389. }
  390.  
  391. // Duplicate last edit time to the top of a post
  392. if(dup_edit_time) {
  393. if(/showtopic=\d+/.test(href) && !/&st=/.test(href)) {
  394. var posts = $$('*[id^="post-main-"]')
  395. for(var i=0, len=posts.length; i<len; i++) {
  396. var edit = $(posts[i], '.edit')
  397. if(edit) {
  398. var last_edit_time = edit.textContent.match(/^This post has been edited by .*: (.*)/)[1]
  399. posts[i].innerHTML = '<p>Last Edited: ' + last_edit_time + '</p><br>' + posts[i].innerHTML
  400. }
  401. }
  402. }
  403. }
  404.  
  405. // Hide top area
  406. if(hide_top_area) {
  407. if(/(showtopic=\d+)|(\bresult_type=posts)/.test(href) && !/act=Msg/i.test(href)) {
  408. var hide_this = true
  409. var topic_id = href.match(/showtopic=(\d+)/)
  410. if(topic_id) { if(dont_clean.indexOf(parseInt(topic_id[1])) != -1) { hide_this = false } }
  411. if($('h3')) { hide_this = false }
  412. if(hide_this) {
  413. if(!/&st=/.test(href)) {
  414. try {
  415. var e = $('.pagecurrent')
  416. var e2 = e.parentNode.parentNode.parentNode.parentNode.parentNode
  417. if(e2 && e2.className == 'ipbtable') { e2.style.display = 'none' }
  418. else { e.parentNode.style.display = 'none' }
  419. } catch(e) {}
  420. try { $$('img[src$="style_images/ambience/cat_top_ls.gif"]')[1].parentNode.parentNode.parentNode.parentNode.parentNode.style.display = 'none' } catch(e) {}
  421. try { $('.subtitle').parentNode.style.display = 'none' } catch(e) {}
  422. }
  423. try { $('td[style*="background-image:url(style_images/ambience/header_eh_textbarbg.jpg)"]').parentNode.parentNode.parentNode.style.display = 'none' } catch(e) {}
  424. try { $('table.mainnav').style.display = 'none' } catch(e) {}
  425. try { $('img[src$="style_images/ambience/cat_top_ls.gif"]').parentNode.parentNode.parentNode.parentNode.parentNode.style.display = 'none' } catch(e) {}
  426. try { $('#userlinks').style.display = 'none' } catch(e) {}
  427. try { $('img[src$="style_images/ambience/ls_main_table_bottom.gif"]').parentNode.parentNode.parentNode.parentNode.parentNode.style.display = 'none' } catch(e) {}
  428. try { $('#navstrip').parentNode.style.display = 'none' } catch(e) {}
  429. try { $('img[src$="style_images/ambience/nav_m.gif"]').parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.style.display = 'none' } catch(e) {}
  430. }
  431. }
  432. }
  433.  
  434. // Hide bottom area
  435. if(hide_bottom_area) {
  436. if(/:\/\/forums\./.test(href) && !/act=Msg/i.test(href)) {
  437. try { $('.borderwrap .formsubtitle').parentNode.style.display = 'none' } catch(e) {}
  438. try { $('.borderwrap .dropdown').parentNode.parentNode.parentNode.parentNode.style.display = 'none' } catch(e) {}
  439. try { $('.copyright').style.display = 'none' } catch(e) {}
  440. try { $$('img[src*="style_images/ambience/expand_main_table."]')[0].parentNode.parentNode.style.display = 'none' } catch(e) {}
  441. try { $$('img[src*="style_images/ambience/expand_main_table."]')[1].parentNode.parentNode.style.display = 'none' } catch(e) {}
  442. }
  443. }
  444.  
  445. // Hide last posts
  446. if(hide_last_posts) {
  447. if(/showforum=/.test(href)) {
  448. var f_hide_last_posts = function() {
  449. //var a = $$('span.lastaction a[href^="http://forums.e-hentai.org/index.php?showuser="], span.lastaction a[href^="https://forums.e-hentai.org/index.php?showuser="]')
  450. var a = $$('span.lastaction a[href$="&view=getlastpost"]')
  451. for(var i=0, len=a.length; i<len; i++) {
  452. var e = doc.createElement('a')
  453. e.text = 'Last'
  454. e.href = a[i].href
  455. a[i].parentNode.parentNode.appendChild(e)
  456. a[i].parentNode.parentNode.removeChild(a[i].parentNode)
  457. }
  458. }
  459. f_hide_last_posts()
  460. //setTimeout(f_hide_last_posts, 1000)
  461. //setTimeout(f_hide_last_posts, 2000)
  462. //setTimeout(f_hide_last_posts, 3000)
  463. //setTimeout(f_hide_last_posts, 4000)
  464. //setTimeout(f_hide_last_posts, 5000)
  465. }
  466. }