Remove Mayhemchan X's header.
This commit is contained in:
parent
df5c84e753
commit
e4535734fc
270
4chan_x.user.js
270
4chan_x.user.js
File diff suppressed because one or more lines are too long
@ -92,12 +92,6 @@ a[href="javascript:;"] {
|
|||||||
.fourchan-x body {
|
.fourchan-x body {
|
||||||
-moz-box-sizing: border-box;
|
-moz-box-sizing: border-box;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
margin-top: 2em;
|
|
||||||
}
|
|
||||||
.fourchan-x #boardNavDesktop,
|
|
||||||
.fourchan-x #navtopright,
|
|
||||||
.fourchan-x #boardNavDesktopFoot {
|
|
||||||
display: none !important;
|
|
||||||
}
|
}
|
||||||
#header {
|
#header {
|
||||||
top: 0;
|
top: 0;
|
||||||
@ -148,9 +142,6 @@ a[href="javascript:;"] {
|
|||||||
#shortcuts:empty {
|
#shortcuts:empty {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
.shortcut:not(:last-child)::after {
|
|
||||||
content: " / ";
|
|
||||||
}
|
|
||||||
.brackets-wrap::before {
|
.brackets-wrap::before {
|
||||||
content: "\\00a0[";
|
content: "\\00a0[";
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,14 @@
|
|||||||
Config =
|
Config =
|
||||||
main:
|
main:
|
||||||
'Miscellaneous':
|
'Miscellaneous':
|
||||||
|
'Catalog Links': [
|
||||||
|
true
|
||||||
|
'Turn Navigation links into links to each board\'s catalog.'
|
||||||
|
]
|
||||||
|
'External Catalog': [
|
||||||
|
false
|
||||||
|
'Link to external catalog instead of the internal one.'
|
||||||
|
]
|
||||||
'Enable 4chan\'s Extension': [
|
'Enable 4chan\'s Extension': [
|
||||||
false
|
false
|
||||||
'Compatibility between <%= meta.name %> and 4chan\'s inline extension is NOT guaranteed.'
|
'Compatibility between <%= meta.name %> and 4chan\'s inline extension is NOT guaranteed.'
|
||||||
|
|||||||
@ -1,50 +1,28 @@
|
|||||||
Header =
|
Header =
|
||||||
init: ->
|
init: ->
|
||||||
headerEl = $.el 'div',
|
@bar = $.el 'div'
|
||||||
id: 'header'
|
@bar.styleText = "position: fixed; top: 0; left: 0; right: 0; height: 0;"
|
||||||
innerHTML: """
|
@shortcuts = $.el 'span',
|
||||||
<div id=header-bar class=dialog>
|
id: 'shortcuts'
|
||||||
<span class='menu-button brackets-wrap'><a href=javascript:;><i></i></a></span>
|
|
||||||
<span id=shortcuts class=brackets-wrap></span>
|
|
||||||
<span id=board-list>
|
|
||||||
<span id=custom-board-list></span>
|
|
||||||
<span id=full-board-list hidden></span>
|
|
||||||
</span>
|
|
||||||
<div id=toggle-header-bar title="Toggle the header auto-hiding."></div>
|
|
||||||
</div>
|
|
||||||
<div id=notifications></div>
|
|
||||||
""".replace />\s+</g, '><' # get rid of spaces between elements
|
|
||||||
|
|
||||||
@bar = $ '#header-bar', headerEl
|
|
||||||
@setBarVisibility Conf['Header auto-hide']
|
|
||||||
$.sync 'Header auto-hide', @setBarVisibility
|
|
||||||
|
|
||||||
@menu = new UI.Menu 'header'
|
|
||||||
$.on $('.menu-button', @bar), 'click', @menuToggle
|
|
||||||
$.on $('#toggle-header-bar', @bar), 'click', @toggleBarVisibility
|
|
||||||
|
|
||||||
catalogToggler = $.el 'label',
|
|
||||||
innerHTML: "<input type=checkbox #{if Conf['Header catalog links'] then 'checked' else ''}> Use catalog board links"
|
|
||||||
$.on catalogToggler.firstElementChild, 'change', @toggleCatalogLinks
|
|
||||||
$.sync 'Header catalog links', @setCatalogLinks
|
|
||||||
$.event 'AddMenuEntry',
|
|
||||||
type: 'header'
|
|
||||||
el: catalogToggler
|
|
||||||
order: 50
|
|
||||||
|
|
||||||
$.asap (-> d.body), ->
|
$.asap (-> d.body), ->
|
||||||
return unless Main.isThisPageLegit()
|
return unless Main.isThisPageLegit()
|
||||||
# Wait for #boardNavMobile instead of #boardNavDesktop,
|
# Wait for #boardNavMobile instead of #boardNavDesktop,
|
||||||
# it might be incomplete otherwise.
|
# it might be incomplete otherwise.
|
||||||
$.asap (-> $.id 'boardNavMobile'), Header.setBoardList
|
$.asap (-> $.id 'boardNavMobile'), Header.setBoardList
|
||||||
$.prepend d.body, headerEl
|
|
||||||
|
|
||||||
setBoardList: ->
|
setBoardList: ->
|
||||||
nav = $.id 'boardNavDesktop'
|
|
||||||
|
Header.nav = nav = $.id 'boardNavDesktop'
|
||||||
if a = $ "a[href*='/#{g.BOARD}/']", nav
|
if a = $ "a[href*='/#{g.BOARD}/']", nav
|
||||||
a.className = 'current'
|
a.className = 'current'
|
||||||
fullBoardList = $ '#full-board-list', Header.bar
|
fullBoardList = $.el 'span',
|
||||||
|
id: 'full-board-list'
|
||||||
|
hidden: true
|
||||||
|
customBoardList = $.el 'span',
|
||||||
|
id: 'custom-board-list'
|
||||||
$.add fullBoardList, [nav.childNodes...]
|
$.add fullBoardList, [nav.childNodes...]
|
||||||
|
$.add nav, [customBoardList, fullBoardList, Header.shortcuts, $ '#navtopright', fullBoardList]
|
||||||
|
$.add d.body, Header.bar
|
||||||
|
|
||||||
if Conf['Custom Board Navigation']
|
if Conf['Custom Board Navigation']
|
||||||
Header.generateBoardList Conf['boardnav']
|
Header.generateBoardList Conf['boardnav']
|
||||||
@ -55,16 +33,14 @@ Header =
|
|||||||
$.on btn, 'click', Header.toggleBoardList
|
$.on btn, 'click', Header.toggleBoardList
|
||||||
$.prepend fullBoardList, btn
|
$.prepend fullBoardList, btn
|
||||||
else
|
else
|
||||||
$.rm $ '#custom-board-list', Header.bar
|
$.rm $ '#custom-board-list', nav
|
||||||
fullBoardList.hidden = false
|
fullBoardList.hidden = false
|
||||||
|
|
||||||
Header.setCatalogLinks Conf['Header catalog links']
|
|
||||||
|
|
||||||
generateBoardList: (text) ->
|
generateBoardList: (text) ->
|
||||||
list = $ '#custom-board-list', Header.bar
|
list = $ '#custom-board-list', Header.nav
|
||||||
list.innerHTML = null
|
list.innerHTML = null
|
||||||
return unless text
|
return unless text
|
||||||
as = $$('#full-board-list a', Header.bar)[0...-2] # ignore the Settings and Home links
|
as = $$('#full-board-list a', Header.nav)
|
||||||
nodes = text.match(/[\w@]+(-(all|title|full|text:"[^"]+"))?|[^\w@]+/g).map (t) ->
|
nodes = text.match(/[\w@]+(-(all|title|full|text:"[^"]+"))?|[^\w@]+/g).map (t) ->
|
||||||
if /^[^\w@]/.test t
|
if /^[^\w@]/.test t
|
||||||
return $.tn t
|
return $.tn t
|
||||||
@ -95,43 +71,18 @@ Header =
|
|||||||
$.add list, nodes
|
$.add list, nodes
|
||||||
|
|
||||||
toggleBoardList: ->
|
toggleBoardList: ->
|
||||||
{bar} = Header
|
{nav} = Header
|
||||||
custom = $ '#custom-board-list', bar
|
custom = $ '#custom-board-list', nav
|
||||||
full = $ '#full-board-list', bar
|
full = $ '#full-board-list', nav
|
||||||
showBoardList = !full.hidden
|
showBoardList = !full.hidden
|
||||||
custom.hidden = !showBoardList
|
custom.hidden = !showBoardList
|
||||||
full.hidden = showBoardList
|
full.hidden = showBoardList
|
||||||
|
|
||||||
setCatalogLinks: (useCatalog) ->
|
|
||||||
as = $$ '#board-list a[href*="boards.4chan.org"]', Header.bar
|
|
||||||
str = if useCatalog then 'catalog' else ''
|
|
||||||
for a in as
|
|
||||||
a.pathname = "/#{a.pathname.split('/')[1]}/#{str}"
|
|
||||||
return
|
|
||||||
toggleCatalogLinks: ->
|
|
||||||
Header.setCatalogLinks @checked
|
|
||||||
$.set 'Header catalog links', @checked
|
|
||||||
|
|
||||||
setBarVisibility: (hide) ->
|
|
||||||
(if hide then $.addClass else $.rmClass) Header.bar, 'autohide'
|
|
||||||
toggleBarVisibility: ->
|
|
||||||
hide = !$.hasClass Header.bar, 'autohide'
|
|
||||||
Header.setBarVisibility hide
|
|
||||||
message = if hide
|
|
||||||
'The header bar will automatically hide itself.'
|
|
||||||
else
|
|
||||||
'The header bar will remain visible.'
|
|
||||||
new Notification 'info', message, 2
|
|
||||||
$.set 'Header auto-hide', hide
|
|
||||||
|
|
||||||
addShortcut: (el) ->
|
addShortcut: (el) ->
|
||||||
shortcut = $.el 'span',
|
shortcut = $.el 'span',
|
||||||
className: 'shortcut'
|
className: 'shortcut'
|
||||||
$.add shortcut, el
|
$.add shortcut, [$.tn(' ['), el, $.tn(']')]
|
||||||
$.prepend $('#shortcuts', Header.bar), shortcut
|
$.add Header.shortcuts, shortcut
|
||||||
|
|
||||||
menuToggle: (e) ->
|
|
||||||
Header.menu.toggle e, @, g
|
|
||||||
|
|
||||||
class Notification
|
class Notification
|
||||||
constructor: (type, content, @timeout) ->
|
constructor: (type, content, @timeout) ->
|
||||||
@ -165,6 +116,54 @@ class Notification
|
|||||||
close = ->
|
close = ->
|
||||||
$.rm @el if @el.parentNode
|
$.rm @el if @el.parentNode
|
||||||
|
|
||||||
|
CatalogLinks =
|
||||||
|
init: ->
|
||||||
|
return unless Conf['Catalog Links']
|
||||||
|
el = $.el 'a',
|
||||||
|
id: 'toggleCatalog'
|
||||||
|
href: 'javascript:;'
|
||||||
|
textContent: 'Catalog Off'
|
||||||
|
$.on el, 'click', @toggle
|
||||||
|
|
||||||
|
Header.addShortcut el
|
||||||
|
|
||||||
|
$.asap (-> d.body), ->
|
||||||
|
return unless Main.isThisPageLegit()
|
||||||
|
# Wait for #boardNavMobile instead of #boardNavDesktop,
|
||||||
|
# it might be incomplete otherwise.
|
||||||
|
$.asap (-> $.id 'boardNavMobile'), ->
|
||||||
|
# Set links on load.
|
||||||
|
CatalogLinks.toggle.call el, true
|
||||||
|
|
||||||
|
toggle: (onLoad) ->
|
||||||
|
if onLoad is true
|
||||||
|
useCatalog = $.get 'CatalogIsToggled', g.VIEW is 'catalog'
|
||||||
|
else
|
||||||
|
$.set 'CatalogIsToggled', useCatalog = @textContent is 'Catalog Off'
|
||||||
|
for a in $$ 'a', $.id('boardNavDesktop')
|
||||||
|
board = a.pathname.split('/')[1]
|
||||||
|
continue if ['f', 'status', '4chan'].contains(board) or !board
|
||||||
|
if Conf['External Catalog']
|
||||||
|
a.href = if useCatalog
|
||||||
|
CatalogLinks.external(board)
|
||||||
|
else
|
||||||
|
"//boards.4chan.org/#{board}/"
|
||||||
|
else
|
||||||
|
a.pathname = "/#{board}/#{if useCatalog then 'catalog' else ''}"
|
||||||
|
a.title = if useCatalog then "#{a.title} - Catalog" else a.title.replace(/\ -\ Catalog$/, '')
|
||||||
|
@textContent = "Catalog #{if useCatalog then 'On' else 'Off'}"
|
||||||
|
@title = "Turn catalog links #{if useCatalog then 'off' else 'on'}."
|
||||||
|
|
||||||
|
external: (board) ->
|
||||||
|
return (
|
||||||
|
if ['a', 'c', 'g', 'co', 'k', 'm', 'o', 'p', 'v', 'vg', 'w', 'cm', '3', 'adv', 'an', 'cgl', 'ck', 'diy', 'fa', 'fit', 'int', 'jp', 'mlp', 'lit', 'mu', 'n', 'po', 'sci', 'toy', 'trv', 'tv', 'vp', 'x', 'q'].contains board
|
||||||
|
"http://catalog.neet.tv/#{board}"
|
||||||
|
else if ['d', 'e', 'gif', 'h', 'hr', 'hc', 'r9k', 's', 'pol', 'soc', 'u', 'i', 'ic', 'hm', 'r', 'w', 'wg', 'wsg', 't', 'y'].contains board
|
||||||
|
"http://4index.gropes.us/#{board}"
|
||||||
|
else
|
||||||
|
"//boards.4chan.org/#{board}/catalog"
|
||||||
|
)
|
||||||
|
|
||||||
Settings =
|
Settings =
|
||||||
init: ->
|
init: ->
|
||||||
# 4chan X settings link
|
# 4chan X settings link
|
||||||
@ -173,22 +172,13 @@ Settings =
|
|||||||
textContent: '<%= meta.name %> Settings'
|
textContent: '<%= meta.name %> Settings'
|
||||||
href: 'javascript:;'
|
href: 'javascript:;'
|
||||||
$.on link, 'click', Settings.open
|
$.on link, 'click', Settings.open
|
||||||
$.event 'AddMenuEntry',
|
|
||||||
type: 'header'
|
|
||||||
el: link
|
|
||||||
order: 111
|
|
||||||
|
|
||||||
# 4chan settings link
|
$.asap (-> d.body), ->
|
||||||
link = $.el 'a',
|
return unless Main.isThisPageLegit()
|
||||||
className: 'fourchan-settings-link'
|
# Wait for #boardNavMobile instead of #boardNavDesktop,
|
||||||
textContent: '4chan Settings'
|
# it might be incomplete otherwise.
|
||||||
href: 'javascript:;'
|
$.asap (-> $.id 'boardNavMobile'), ->
|
||||||
$.on link, 'click', -> $.id('settingsWindowLink').click()
|
$.prepend $.id('navtopright'), [$.tn(' ['), link, $.tn('] ')]
|
||||||
$.event 'AddMenuEntry',
|
|
||||||
type: 'header'
|
|
||||||
el: link
|
|
||||||
order: 110
|
|
||||||
open: -> Conf['Enable 4chan\'s Extension']
|
|
||||||
|
|
||||||
unless $.get 'previousversion'
|
unless $.get 'previousversion'
|
||||||
$.set 'previousversion', g.VERSION
|
$.set 'previousversion', g.VERSION
|
||||||
@ -680,7 +670,7 @@ Fourchan =
|
|||||||
|
|
||||||
CustomCSS =
|
CustomCSS =
|
||||||
init: ->
|
init: ->
|
||||||
return if !Conf['Custom CSS']
|
return unless Conf['Custom CSS']
|
||||||
@addStyle()
|
@addStyle()
|
||||||
addStyle: ->
|
addStyle: ->
|
||||||
@style = $.addStyle Conf['usercss']
|
@style = $.addStyle Conf['usercss']
|
||||||
@ -3095,13 +3085,37 @@ ImageExpand =
|
|||||||
init: ->
|
init: ->
|
||||||
return if g.VIEW is 'catalog' or !Conf['Image Expansion']
|
return if g.VIEW is 'catalog' or !Conf['Image Expansion']
|
||||||
|
|
||||||
@EAI = $.el 'a',
|
wrapper = $.el 'div',
|
||||||
className: 'expand-all-shortcut'
|
id: 'imgControls'
|
||||||
textContent: 'EAI'
|
innerHTML: """
|
||||||
title: 'Expand All Images'
|
<a class='expand-all-shortcut' title='Expand All Images' href='javascript:;'>Expand All Images</a>
|
||||||
href: 'javascript:;'
|
<a class='menu-button' href='javascript:;'>[<i></i>]</a>
|
||||||
|
"""
|
||||||
|
@EAI = wrapper.firstElementChild
|
||||||
$.on @EAI, 'click', ImageExpand.cb.toggleAll
|
$.on @EAI, 'click', ImageExpand.cb.toggleAll
|
||||||
Header.addShortcut @EAI
|
|
||||||
|
@menu = new UI.Menu 'imageexpand'
|
||||||
|
$.on $('.menu-button', wrapper), 'click', @menuToggle
|
||||||
|
|
||||||
|
for type, config of Config.imageExpansion
|
||||||
|
label = $.el 'label',
|
||||||
|
innerHTML: "<input type=checkbox name='#{type}'> #{type}"
|
||||||
|
input = label.firstElementChild
|
||||||
|
if ['Fit width', 'Fit height'].contains type
|
||||||
|
$.on input, 'change', ImageExpand.cb.setFitness
|
||||||
|
|
||||||
|
if config
|
||||||
|
label.title = config[1]
|
||||||
|
input.checked = Conf[type]
|
||||||
|
$.event 'change', null, input
|
||||||
|
$.on input, 'change', $.cb.checked
|
||||||
|
|
||||||
|
$.event 'AddMenuEntry',
|
||||||
|
type: 'imageexpand'
|
||||||
|
el: label
|
||||||
|
|
||||||
|
$.asap (-> $.id 'delform'), ->
|
||||||
|
$.prepend $.id('delform'), wrapper
|
||||||
|
|
||||||
Post::callbacks.push
|
Post::callbacks.push
|
||||||
name: 'Image Expansion'
|
name: 'Image Expansion'
|
||||||
@ -3235,41 +3249,12 @@ ImageExpand =
|
|||||||
clearTimeout timeoutID
|
clearTimeout timeoutID
|
||||||
post.kill true
|
post.kill true
|
||||||
|
|
||||||
menu:
|
|
||||||
init: ->
|
|
||||||
return if g.VIEW is 'catalog' or !Conf['Image Expansion']
|
|
||||||
|
|
||||||
el = $.el 'span',
|
|
||||||
textContent: 'Image Expansion'
|
|
||||||
className: 'image-expansion-link'
|
|
||||||
|
|
||||||
{createSubEntry} = ImageExpand.menu
|
|
||||||
subEntries = []
|
|
||||||
for key, conf of Config.imageExpansion
|
|
||||||
subEntries.push createSubEntry key, conf
|
|
||||||
|
|
||||||
$.event 'AddMenuEntry',
|
|
||||||
type: 'header'
|
|
||||||
el: el
|
|
||||||
order: 80
|
|
||||||
subEntries: subEntries
|
|
||||||
|
|
||||||
createSubEntry: (type, config) ->
|
|
||||||
label = $.el 'label',
|
|
||||||
innerHTML: "<input type=checkbox name='#{type}'> #{type}"
|
|
||||||
input = label.firstElementChild
|
|
||||||
if ['Fit width', 'Fit height'].contains type
|
|
||||||
$.on input, 'change', ImageExpand.cb.setFitness
|
|
||||||
if config
|
|
||||||
label.title = config[1]
|
|
||||||
input.checked = Conf[type]
|
|
||||||
$.event 'change', null, input
|
|
||||||
$.on input, 'change', $.cb.checked
|
|
||||||
el: label
|
|
||||||
|
|
||||||
resize: ->
|
resize: ->
|
||||||
ImageExpand.style.textContent = ":root.fit-height .full-image {max-height:#{doc.clientHeight}px}"
|
ImageExpand.style.textContent = ":root.fit-height .full-image {max-height:#{doc.clientHeight}px}"
|
||||||
|
|
||||||
|
menuToggle: (e) ->
|
||||||
|
ImageExpand.menu.toggle e, @, g
|
||||||
|
|
||||||
RevealSpoilers =
|
RevealSpoilers =
|
||||||
init: ->
|
init: ->
|
||||||
return if g.VIEW is 'catalog' or !Conf['Reveal Spoilers']
|
return if g.VIEW is 'catalog' or !Conf['Reveal Spoilers']
|
||||||
|
|||||||
@ -340,6 +340,7 @@ Main =
|
|||||||
initFeatures
|
initFeatures
|
||||||
'Polyfill': Polyfill
|
'Polyfill': Polyfill
|
||||||
'Header': Header
|
'Header': Header
|
||||||
|
'Catalog Links': CatalogLinks
|
||||||
'Settings': Settings
|
'Settings': Settings
|
||||||
'Fourchan thingies': Fourchan
|
'Fourchan thingies': Fourchan
|
||||||
'Custom CSS': CustomCSS
|
'Custom CSS': CustomCSS
|
||||||
@ -371,7 +372,6 @@ Main =
|
|||||||
'File Info Formatting': FileInfo
|
'File Info Formatting': FileInfo
|
||||||
'Sauce': Sauce
|
'Sauce': Sauce
|
||||||
'Image Expansion': ImageExpand
|
'Image Expansion': ImageExpand
|
||||||
'Image Expansion (Menu)': ImageExpand.menu
|
|
||||||
'Reveal Spoilers': RevealSpoilers
|
'Reveal Spoilers': RevealSpoilers
|
||||||
'Image Replace': ImageReplace
|
'Image Replace': ImageReplace
|
||||||
'Image Hover': ImageHover
|
'Image Hover': ImageHover
|
||||||
@ -519,6 +519,7 @@ Main =
|
|||||||
|
|
||||||
parseError: (data) ->
|
parseError: (data) ->
|
||||||
{message, error} = data
|
{message, error} = data
|
||||||
|
c.log message, error
|
||||||
c.log message, error.stack
|
c.log message, error.stack
|
||||||
message = $.el 'div',
|
message = $.el 'div',
|
||||||
textContent: message
|
textContent: message
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user