Merge branch 'v3'
Conflicts: builds/appchan-x.user.js builds/crx/script.js src/General/css/yotsuba-b.css src/Images/FappeTyme.coffee
This commit is contained in:
commit
7301f43289
@ -4301,7 +4301,7 @@
|
||||
return;
|
||||
}
|
||||
as = $$('#full-board-list a[title]', Header.boardList);
|
||||
re = /[\w@]+(-(all|title|replace|full|archive|(mode|sort|text|url):"[^"]+"))*|[^\w@]+/g;
|
||||
re = /[\w@]+(-(all|title|replace|full|archive|(mode|sort|text|url):"[^"]+"(\,"[^"]+[^"]")?))*|[^\w@]+/g;
|
||||
nodes = text.match(re).map(function(t) {
|
||||
var a, board, boardID, href, m, type, _i, _len;
|
||||
if (/^[^\w@]/.test(t)) {
|
||||
@ -10585,7 +10585,7 @@
|
||||
FappeTyme = {
|
||||
init: function() {
|
||||
var el, lc, type, _i, _len, _ref;
|
||||
if (!(Conf['Fappe Tyme'] || Conf['Werk Tyme']) || g.VIEW === 'catalog' || g.BOARD.ID === 'f') {
|
||||
if (!(Conf['Fappe Tyme'] || Conf['Werk Tyme']) || g.BOARD === 'f') {
|
||||
return;
|
||||
}
|
||||
_ref = ["Fappe", "Werk"];
|
||||
@ -10640,7 +10640,7 @@
|
||||
Gallery = {
|
||||
init: function() {
|
||||
var el;
|
||||
if (g.VIEW === 'catalog' || g.BOARD === 'f' || !Conf['Gallery']) {
|
||||
if (g.BOARD === 'f' || !Conf['Gallery']) {
|
||||
return;
|
||||
}
|
||||
el = $.el('a', {
|
||||
@ -10893,7 +10893,7 @@
|
||||
menu: {
|
||||
init: function() {
|
||||
var createSubEntry, el, name, subEntries;
|
||||
if (g.VIEW === 'catalog' || !Conf['Gallery']) {
|
||||
if (!Conf['Gallery']) {
|
||||
return;
|
||||
}
|
||||
el = $.el('span', {
|
||||
@ -16468,7 +16468,7 @@
|
||||
Navigate = {
|
||||
path: window.location.pathname,
|
||||
init: function() {
|
||||
if (g.VIEW === 'catalog' || g.BOARD.ID === 'f' || !Conf['JSON Navigation']) {
|
||||
if (g.BOARD.ID === 'f' || !Conf['JSON Navigation']) {
|
||||
return;
|
||||
}
|
||||
$.ready(function() {
|
||||
|
||||
@ -4360,7 +4360,7 @@
|
||||
return;
|
||||
}
|
||||
as = $$('#full-board-list a[title]', Header.boardList);
|
||||
re = /[\w@]+(-(all|title|replace|full|archive|(mode|sort|text|url):"[^"]+"))*|[^\w@]+/g;
|
||||
re = /[\w@]+(-(all|title|replace|full|archive|(mode|sort|text|url):"[^"]+"(\,"[^"]+[^"]")?))*|[^\w@]+/g;
|
||||
nodes = text.match(re).map(function(t) {
|
||||
var a, board, boardID, href, m, type, _i, _len;
|
||||
if (/^[^\w@]/.test(t)) {
|
||||
@ -10622,7 +10622,7 @@
|
||||
FappeTyme = {
|
||||
init: function() {
|
||||
var el, lc, type, _i, _len, _ref;
|
||||
if (!(Conf['Fappe Tyme'] || Conf['Werk Tyme']) || g.VIEW === 'catalog' || g.BOARD.ID === 'f') {
|
||||
if (!(Conf['Fappe Tyme'] || Conf['Werk Tyme']) || g.BOARD === 'f') {
|
||||
return;
|
||||
}
|
||||
_ref = ["Fappe", "Werk"];
|
||||
@ -10677,7 +10677,7 @@
|
||||
Gallery = {
|
||||
init: function() {
|
||||
var el;
|
||||
if (g.VIEW === 'catalog' || g.BOARD === 'f' || !Conf['Gallery']) {
|
||||
if (g.BOARD === 'f' || !Conf['Gallery']) {
|
||||
return;
|
||||
}
|
||||
el = $.el('a', {
|
||||
@ -10930,7 +10930,7 @@
|
||||
menu: {
|
||||
init: function() {
|
||||
var createSubEntry, el, name, subEntries;
|
||||
if (g.VIEW === 'catalog' || !Conf['Gallery']) {
|
||||
if (!Conf['Gallery']) {
|
||||
return;
|
||||
}
|
||||
el = $.el('span', {
|
||||
@ -16488,7 +16488,7 @@
|
||||
Navigate = {
|
||||
path: window.location.pathname,
|
||||
init: function() {
|
||||
if (g.VIEW === 'catalog' || g.BOARD.ID === 'f' || !Conf['JSON Navigation']) {
|
||||
if (g.BOARD.ID === 'f' || !Conf['JSON Navigation']) {
|
||||
return;
|
||||
}
|
||||
$.ready(function() {
|
||||
|
||||
@ -1,210 +0,0 @@
|
||||
ThreadHiding =
|
||||
init: ->
|
||||
return if g.VIEW isnt 'index' or !Conf['Thread Hiding Buttons'] and !Conf['Thread Hiding Link']
|
||||
|
||||
@db = new DataBoard 'hiddenThreads'
|
||||
@syncCatalog()
|
||||
$.on d, 'IndexBuild', @onIndexBuild
|
||||
Thread.callbacks.push
|
||||
name: 'Thread Hiding'
|
||||
cb: @node
|
||||
|
||||
node: ->
|
||||
if data = ThreadHiding.db.get {boardID: @board.ID, threadID: @ID}
|
||||
ThreadHiding.hide @, data.makeStub
|
||||
return unless Conf['Thread Hiding Buttons']
|
||||
$.prepend @OP.nodes.info, ThreadHiding.makeButton @, 'hide'
|
||||
|
||||
onIndexBuild: ({detail: nodes}) ->
|
||||
for root, i in nodes by 2
|
||||
thread = Get.threadFromRoot root
|
||||
continue unless thread.isHidden
|
||||
unless thread.stub
|
||||
nodes[i + 1].hidden = true
|
||||
else unless root.contains thread.stub
|
||||
# When we come back to a page, the stub is already there.
|
||||
ThreadHiding.makeStub thread, root
|
||||
return
|
||||
|
||||
syncCatalog: ->
|
||||
# Sync hidden threads from the catalog into the index.
|
||||
hiddenThreads = ThreadHiding.db.get
|
||||
boardID: g.BOARD.ID
|
||||
defaultValue: {}
|
||||
hiddenThreadsOnCatalog = JSON.parse(localStorage.getItem "4chan-hide-t-#{g.BOARD}") or {}
|
||||
|
||||
# Add threads that were hidden in the catalog.
|
||||
for threadID of hiddenThreadsOnCatalog
|
||||
unless threadID of hiddenThreads
|
||||
hiddenThreads[threadID] = {}
|
||||
|
||||
# Remove threads that were un-hidden in the catalog.
|
||||
for threadID of hiddenThreads
|
||||
unless threadID of hiddenThreadsOnCatalog
|
||||
delete hiddenThreads[threadID]
|
||||
|
||||
if (ThreadHiding.db.data.lastChecked or 0) > Date.now() - $.MINUTE
|
||||
# Was cleaned just now.
|
||||
ThreadHiding.cleanCatalog hiddenThreadsOnCatalog
|
||||
|
||||
ThreadHiding.db.set
|
||||
boardID: g.BOARD.ID
|
||||
val: hiddenThreads
|
||||
|
||||
cleanCatalog: (hiddenThreadsOnCatalog) ->
|
||||
# We need to clean hidden threads on the catalog ourselves,
|
||||
# otherwise if we don't visit the catalog regularly
|
||||
# it will pollute the localStorage and our data.
|
||||
$.cache "//a.4cdn.org/#{g.BOARD}/threads.json", ->
|
||||
return unless @status is 200
|
||||
threads = {}
|
||||
for page in @response
|
||||
for thread in page.threads
|
||||
if thread.no of hiddenThreadsOnCatalog
|
||||
threads[thread.no] = hiddenThreadsOnCatalog[thread.no]
|
||||
if Object.keys(threads).length
|
||||
localStorage.setItem "4chan-hide-t-#{g.BOARD}", JSON.stringify threads
|
||||
else
|
||||
localStorage.removeItem "4chan-hide-t-#{g.BOARD}"
|
||||
|
||||
menu:
|
||||
init: ->
|
||||
return if g.VIEW isnt 'index' or !Conf['Menu'] or !Conf['Thread Hiding Link']
|
||||
|
||||
div = $.el 'div',
|
||||
className: 'hide-thread-link'
|
||||
textContent: 'Hide thread'
|
||||
|
||||
apply = $.el 'a',
|
||||
textContent: 'Apply'
|
||||
href: 'javascript:;'
|
||||
$.on apply, 'click', ThreadHiding.menu.hide
|
||||
|
||||
makeStub = $.el 'label',
|
||||
innerHTML: "<input type=checkbox #{if Conf['Stubs'] then 'checked' else ''}> Make stub"
|
||||
|
||||
$.event 'AddMenuEntry',
|
||||
type: 'post'
|
||||
el: div
|
||||
order: 20
|
||||
open: ({thread, isReply}) ->
|
||||
if isReply or thread.isHidden
|
||||
return false
|
||||
ThreadHiding.menu.thread = thread
|
||||
true
|
||||
subEntries: [el: apply; el: makeStub]
|
||||
|
||||
div = $.el 'a',
|
||||
className: 'show-thread-link'
|
||||
textContent: 'Show thread'
|
||||
href: 'javascript:;'
|
||||
$.on div, 'click', ThreadHiding.menu.show
|
||||
|
||||
$.event 'AddMenuEntry',
|
||||
type: 'post'
|
||||
el: div
|
||||
order: 20
|
||||
open: ({thread, isReply}) ->
|
||||
if isReply or !thread.isHidden
|
||||
return false
|
||||
ThreadHiding.menu.thread = thread
|
||||
true
|
||||
|
||||
hideStubLink = $.el 'a',
|
||||
textContent: 'Hide stub'
|
||||
href: 'javascript:;'
|
||||
$.on hideStubLink, 'click', ThreadHiding.menu.hideStub
|
||||
|
||||
$.event 'AddMenuEntry',
|
||||
type: 'post'
|
||||
el: hideStubLink
|
||||
order: 15
|
||||
open: ({thread, isReply}) ->
|
||||
if isReply or !thread.isHidden
|
||||
return false
|
||||
ThreadHiding.menu.thread = thread
|
||||
|
||||
hide: ->
|
||||
makeStub = $('input', @parentNode).checked
|
||||
{thread} = ThreadHiding.menu
|
||||
ThreadHiding.hide thread, makeStub
|
||||
ThreadHiding.saveHiddenState thread, makeStub
|
||||
$.event 'CloseMenu'
|
||||
|
||||
show: ->
|
||||
{thread} = ThreadHiding.menu
|
||||
ThreadHiding.show thread
|
||||
ThreadHiding.saveHiddenState thread
|
||||
$.event 'CloseMenu'
|
||||
|
||||
hideStub: ->
|
||||
{thread} = ThreadHiding.menu
|
||||
ThreadHiding.hide thread, false
|
||||
$.event 'CloseMenu'
|
||||
return
|
||||
|
||||
makeButton: (thread, type) ->
|
||||
a = PostHiding.makeButton type, true
|
||||
a.className = "#{type}-thread-button"
|
||||
a.dataset.fullID = thread.fullID
|
||||
$.on a, 'click', ThreadHiding.toggle
|
||||
a
|
||||
|
||||
makeStub: (thread, root) ->
|
||||
numReplies = $$('.thread > .replyContainer', root).length
|
||||
numReplies += +summary.textContent.match /\d+/ if summary = $ '.summary', root
|
||||
opInfo = if Conf['Anonymize']
|
||||
'Anonymous'
|
||||
else
|
||||
$('.nameBlock', thread.OP.nodes.info).textContent
|
||||
|
||||
a = ThreadHiding.makeButton thread, 'show'
|
||||
$.add a, $.tn " #{opInfo} (#{if numReplies is 1 then '1 reply' else "#{numReplies} replies"})"
|
||||
thread.stub = $.el 'div',
|
||||
className: 'stub'
|
||||
if Conf['Menu']
|
||||
$.add thread.stub, [a, Menu.makeButton()]
|
||||
else
|
||||
$.add thread.stub, a
|
||||
$.prepend root, thread.stub
|
||||
|
||||
saveHiddenState: (thread, makeStub) ->
|
||||
hiddenThreadsOnCatalog = JSON.parse(localStorage.getItem "4chan-hide-t-#{g.BOARD}") or {}
|
||||
if thread.isHidden
|
||||
ThreadHiding.db.set
|
||||
boardID: thread.board.ID
|
||||
threadID: thread.ID
|
||||
val: {makeStub}
|
||||
hiddenThreadsOnCatalog[thread] = true
|
||||
else
|
||||
ThreadHiding.db.delete
|
||||
boardID: thread.board.ID
|
||||
threadID: thread.ID
|
||||
delete hiddenThreadsOnCatalog[thread]
|
||||
localStorage.setItem "4chan-hide-t-#{g.BOARD}", JSON.stringify hiddenThreadsOnCatalog
|
||||
|
||||
toggle: (thread) ->
|
||||
unless thread instanceof Thread
|
||||
thread = g.threads[@dataset.fullID]
|
||||
if thread.isHidden
|
||||
ThreadHiding.show thread
|
||||
else
|
||||
ThreadHiding.hide thread
|
||||
ThreadHiding.saveHiddenState thread
|
||||
|
||||
hide: (thread, makeStub=Conf['Stubs']) ->
|
||||
return if thread.isHidden
|
||||
threadRoot = thread.OP.nodes.root.parentNode
|
||||
thread.isHidden = true
|
||||
|
||||
return threadRoot.hidden = threadRoot.nextElementSibling.hidden = true unless makeStub # <hr>
|
||||
|
||||
ThreadHiding.makeStub thread, threadRoot
|
||||
|
||||
show: (thread) ->
|
||||
if thread.stub
|
||||
$.rm thread.stub
|
||||
delete thread.stub
|
||||
threadRoot = thread.OP.nodes.root.parentNode
|
||||
threadRoot.nextElementSibling.hidden =
|
||||
threadRoot.hidden = thread.isHidden = false
|
||||
@ -146,7 +146,7 @@ Header =
|
||||
$.rmAll list
|
||||
return unless text
|
||||
as = $$ '#full-board-list a[title]', Header.boardList
|
||||
re = /[\w@]+(-(all|title|replace|full|archive|(mode|sort|text|url):"[^"]+"))*|[^\w@]+/g
|
||||
re = /[\w@]+(-(all|title|replace|full|archive|(mode|sort|text|url):"[^"]+"(\,"[^"]+[^"]")?))*|[^\w@]+/g
|
||||
nodes = text.match(re).map (t) ->
|
||||
if /^[^\w@]/.test t
|
||||
return $.tn t
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
Navigate =
|
||||
path: window.location.pathname
|
||||
init: ->
|
||||
return if g.VIEW is 'catalog' or g.BOARD.ID is 'f' or !Conf['JSON Navigation']
|
||||
return if g.BOARD.ID is 'f' or !Conf['JSON Navigation']
|
||||
|
||||
$.ready ->
|
||||
# blink/webkit throw a popstate on page load. Not what we want.
|
||||
@ -147,7 +147,6 @@ Navigate =
|
||||
Style.setTheme theme
|
||||
|
||||
updateTitle: ({board, title}) ->
|
||||
$.id('catalog').href = $.id('cataloglink').href = "//boards.4chan.org/#{g.BOARD}/catalog"
|
||||
$.rm subtitle if subtitle = $ '.boardSubtitle'
|
||||
$('.boardTitle').textContent = d.title = "/#{board}/ - #{title}"
|
||||
|
||||
|
||||
@ -605,9 +605,6 @@ nav a,
|
||||
#navNext {
|
||||
<%= order %>: 80;
|
||||
}
|
||||
#catalog {
|
||||
<%= order %>: 90;
|
||||
}
|
||||
#returnIcon {
|
||||
<%= order %>: 100;
|
||||
}
|
||||
@ -677,9 +674,6 @@ nav a,
|
||||
#img-controls {
|
||||
background-position: 0 -90px;
|
||||
}
|
||||
#catalog {
|
||||
background-position: 0 -120px;
|
||||
}
|
||||
#fappeTyme {
|
||||
background-position: 0 -135px;
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
FappeTyme =
|
||||
init: ->
|
||||
return if !(Conf['Fappe Tyme'] or Conf['Werk Tyme']) or g.VIEW is 'catalog' or g.BOARD.ID is 'f'
|
||||
return if !(Conf['Fappe Tyme'] or Conf['Werk Tyme']) or g.BOARD is 'f'
|
||||
|
||||
for type in ["Fappe", "Werk"] when Conf["#{type} Tyme"]
|
||||
lc = type.toLowerCase()
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
Gallery =
|
||||
init: ->
|
||||
return if g.VIEW is 'catalog' or g.BOARD is 'f' or !Conf['Gallery']
|
||||
return if g.BOARD is 'f' or !Conf['Gallery']
|
||||
|
||||
el = $.el 'a',
|
||||
href: 'javascript:;'
|
||||
@ -229,7 +229,7 @@ Gallery =
|
||||
|
||||
menu:
|
||||
init: ->
|
||||
return if g.VIEW is 'catalog' or !Conf['Gallery']
|
||||
return if !Conf['Gallery']
|
||||
|
||||
el = $.el 'span',
|
||||
textContent: 'Gallery'
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user