Merge branch 'v3' of https://github.com/zixaphir/appchan-x
This commit is contained in:
commit
a3da2b3cfc
450
builds/4chan-X.user.js
Executable file → Normal file
450
builds/4chan-X.user.js
Executable file → Normal file
File diff suppressed because one or more lines are too long
450
builds/crx/script.js
Executable file → Normal file
450
builds/crx/script.js
Executable file → Normal file
File diff suppressed because one or more lines are too long
@ -2,7 +2,7 @@ Linkify =
|
|||||||
init: ->
|
init: ->
|
||||||
return if g.VIEW is 'catalog' or not Conf['Linkify']
|
return if g.VIEW is 'catalog' or not Conf['Linkify']
|
||||||
|
|
||||||
@regString =
|
@regString =
|
||||||
///(
|
///(
|
||||||
# http, magnet, ftp, etc
|
# http, magnet, ftp, etc
|
||||||
(https?|mailto|git|magnet|ftp|irc):(
|
(https?|mailto|git|magnet|ftp|irc):(
|
||||||
@ -105,23 +105,29 @@ Linkify =
|
|||||||
|
|
||||||
makeLink: (range) ->
|
makeLink: (range) ->
|
||||||
text = range.toString()
|
text = range.toString()
|
||||||
|
|
||||||
trim = ->
|
|
||||||
range.setEnd range.endContainer, range.endOffset - 1 unless range.endOffset < 1
|
|
||||||
text = text.slice 0, -1
|
|
||||||
|
|
||||||
# Clean leading brackets
|
# Clean leading brackets, >
|
||||||
if /[(\[{<]/.test text.charAt 0
|
i = 0
|
||||||
text = text.slice 1
|
i++ while /[(\[{<>]/.test text.charAt i
|
||||||
unless range.startOffset is range.startContainer.data.length
|
|
||||||
range.setStart range.startContainer, range.startOffset + 1
|
if i
|
||||||
|
text = text.slice i
|
||||||
|
i-- while range.startOffset + i >= range.startContainer.data.length
|
||||||
|
|
||||||
|
range.setStart range.startContainer, range.startOffset + i if i
|
||||||
|
|
||||||
# Clean hanging brackets, commas, periods
|
# Clean hanging brackets, commas, periods
|
||||||
while /[)\]}>.,]/.test char = text.charAt text.length - 1
|
i = 0
|
||||||
if /[.,]/.test(char) or (text.match /[()\[\]{}<>]/g).length % 2
|
while /[)\]}>.,]/.test char = text.charAt text.length - (1 + i)
|
||||||
trim()
|
break unless /[.,]/.test(char) or (text.match /[()\[\]{}<>]/g).length % 2
|
||||||
continue
|
i++
|
||||||
break
|
|
||||||
|
if i
|
||||||
|
text = text.slice 0, -i
|
||||||
|
i-- while range.endOffset > i
|
||||||
|
|
||||||
|
if i
|
||||||
|
range.setEnd range.endContainer, range.endOffset - i
|
||||||
|
|
||||||
# This is the only piece of code left based on Anthony Lieuallen's Linkify
|
# This is the only piece of code left based on Anthony Lieuallen's Linkify
|
||||||
text =
|
text =
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user