Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

quote optimizer userscript

Name: Anonymous 2017-12-27 6:02

turns:

>>15
>>97
>>12
>>11
>>10
>>3
>>6
>>14
>>1
>>100
>>96
fucking niggers


into:

>>1,3,6,10-12,14-15,96-97,100
fucking niggers


includes convenient button underneath post reply form.

// ==UserScript==
// @name Optimize Your Quotes
// @match https://freesoftwarefoundation.org/*
// @match http://freesoftwarefoundation.org/*
// @grant none
// ==/UserScript==

const partition = l => l.sort((a, b) => a - b).reduce((parts, x) => {
let last = parts[parts.length-1]
if (last.length === 0 || (x-1) === last[last.length-1]) {
return [...parts.slice(0, parts.length-1),
[...last, x]]
}
if (last[last.length-1] === x) {
return parts
}
return [...parts, [x]]
}, [[]])

const toText = parts => parts.map(p => p.length > 1 ? [p[0], p[p.length-1]].join('-') : p[0].toString()).join(',')

const reFindUnoptimizedQuotesBlock = /(>>\d+(\n|$))+/g
const reFindUnoptimizedQuotes = /(?:>>)(\d+)(?:\n)/g

const parse = raw => {
let ret = []
for (let m = reFindUnoptimizedQuotes.exec(raw); !!m; m = reFindUnoptimizedQuotes.exec(raw)) {
let n = parseInt(m[1])
ret.push(n)
console.log(`n=${n}`)
}
return ret
}

(function() {
let form = document.querySelector('form')
let textarea = document.querySelector('form > table > tbody > tr:nth-child(2) > td:nth-child(2) > textarea')
if (!!form && !!textarea) {
var btn = document.createElement('a')
btn.innerHTML = 'Optimize Quotes'
btn.setAttribute('href', 'javascript:void(0)')
btn.addEventListener('click', function() {
let t = textarea.value.slice()
for (let m = reFindUnoptimizedQuotesBlock.exec(t); !!m; m = reFindUnoptimizedQuotesBlock.exec(t)) {
let parsed = parse(m[0])
if (parsed.length > 0) {
let parts = partition(parsed)
let optimized = '>>' + toText(parts) + '\n'
textarea.value = textarea.value.replace(m[0], optimized)
}
}
})
form.appendChild(btn)
}
})()

Name: Anonymous 2017-12-27 8:25

>>2
I forgot that this site had two addresses.

Name: Anonymous 2017-12-27 11:48

Kind of nice, I guess, although I think I'd rahter just write the optimized quotes straight from the get-go rather than writing out all those quotes.

Name: Anonymous 2017-12-27 14:25

>>3
What this goy said

Name: Anonymous 2017-12-28 2:31

>>2
don't use freesoftwarefoundation.org, that domain is not controlled by Tinychan proper and leaves you open to a phishing attack.

Name: Anonymous 2017-12-28 4:10

>>5
When I first stumbled upon this site, I always used it (until I realized that the site is on tinychan's domain), and never had any "phishing" attack happen. Though, I agree with you on not using it, the domain name is too long, and it was most likely created as a humorous joke .

Name: Anonymous 2017-12-28 4:15

>>6
I think he meant that you might think that website is actually fsf.org and get phished.

Name: Anonymous 2017-12-28 7:50

>>7
I interpreted that as saying that the domain might eventually be dropped and change hands with a less benevolent party.

Name: Anonymous 2017-12-29 15:01

>>8
Same, though it would be rather strange if an anon board suddenly starting asking for personal info. So not exactly the best target for phishing.

Name: Anonymous 2018-01-02 3:36

>>9
It would be kind of strange, but I'd still submit the info they asked for if it was a board I trusted such as this one. However, the tinychan board doesn't actually own the freesftwarefoundation.org domain, it is on loan to them. Which means, at some point, the domain could become a phishing vector if it falls into the wrong hands.

Name: Anonymous 2018-01-02 19:39

>>10
Yeah, if that happens, only the dumbest of the dummy cats will fall for it, and nothing of value will have been lost.

Name: Anonymous 2018-01-03 8:28

>>11
Would you be one of those dummy cats? That would explain your horrendous (mis)use of the coma.

Name: Anonymous 2018-01-03 9:29

>>12
I don't see anything wrong with that sentence, meow.
Yeah, if that happens
In this case, the word ``yeah'' is an interject that's offset by the comma.
if that happens, only the dumbest of the dummy cats will fall for it
This part joins a dependant clause with a complete one. Commas are also used to delineate if-and statements, meow.
for it, and nothing of value will have been lost.
A comma can be used in front of a conjunction to join two complete sentences. I'm not a grammar export, though; I'm just a dummy cat, meow.

Name: Anonymous 2018-01-03 19:54

>>12
That would explain your horrendous (mis)use of the coma.
How does one "(mis)use" a "coma?"

Name: Anonymous 2018-01-03 20:14

>>13
No, no, no, no, no, no! That's splicing and it is not allowed.
>>14 see >>15

Name: Anonymous 2018-01-03 20:25

>>15
Comma splicing aside, my point still stands. fsf.org was created as a domain on
1991-02-01
and if you fall for phishing scam thinking that freesoftwarefoundation.org is the original, it can safely be said that you're hopeless.

Name: Anonymous 2018-01-03 22:11

>>15
It's not a comma splice if you're using a conjunction, meow.

Name: Anonymous 2018-01-04 4:52

>>17
Conjunctions require a semi-colon.

Name: Anonymous 2018-01-04 10:39

>>18
They most certainly don't. That literally defeats the whole point of conjunctions.

Name: Anonymous 2018-01-06 5:09

I use a + if I'm using a conjunction.

Name: Anonymous 2018-01-07 12:31

CHeck my dubs.

Name: Anonymous 2018-01-07 22:40

>>21
Fuck off.

Name: Anonymous 2018-01-08 10:49

Check dubs

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List