Skip to content

Commit

Permalink
The shame is strong in this one.
Browse files Browse the repository at this point in the history
  • Loading branch information
Aralun committed Apr 20, 2016
1 parent ab94c89 commit 77a0577
Showing 1 changed file with 14 additions and 27 deletions.
41 changes: 14 additions & 27 deletions chat.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,46 +4,33 @@
// @description Random chat improvements
// @include *://chat.stackoverflow.com/rooms/*
// @version 1
// @grant none
// @resource TimeLineStyle https://github.com/Aralun/SO-chat-things/raw/master/chat.css
// @grant GM_addStyle
// @grant GM_getResourceText
// @eat waffle
// ==/UserScript==

window.Plop = window.Plop || {}
Plopify = (...args) => Object.assign(Plop, ...args)
window.eval('window.Plop = window.Plop || {}')
Plopify = (...args) => Object.assign(window.eval('window.Plop'), ...args)

CHAT.addEventHandlerHook(({event_type, time_stamp, message_id}) => {

const timestampAdder = ({event_type, time_stamp, message_id}) => {
if(event_type === 1) {
// We need the HTML element to exist, it's set synchronously
// Thus, queue the query
setTimeout(() => {
// Add timestamp to the message itself
document.getElementById(`message-${message_id}`)
.setAttribute('timestamp', time_stamp)

const element = document.getElementById(`message-${message_id}`)
if (element) {
element.setAttribute('timestamp', time_stamp)
}
}, 0);
}
})

GM.addStyle(
`
.two-minutes {
border-top-style: solid;
border-top-color: red;
border-top-width: thin;
}

.five-minutes {
border-top-style: solid;
border-top-color: green;
border-top-width: thin;
}
window.eval('window.CHAT.addEventHandlerHook(' + timestampAdder.toString() + ')')

.ten-minutes {
border-top-style: solid;
border-top-color: blue;
border-top-width: thin;
}
`
)
GM_addStyle(GM_getResourceText('TimeLineStyle'))

// Add some magic
HTMLCollection.prototype[Symbol.iterator] =
Expand Down

0 comments on commit 77a0577

Please sign in to comment.