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 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.

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