Last active
November 19, 2019 16:37
-
-
Save kms70847/423dc31f346d9a932244 to your computer and use it in GitHub Desktop.
In SO chat, adds a label indicating the character count of your message
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name char count adder (SO Chat) | |
// @namespace . | |
// @description Adds a label indicating the character count of your message | |
// @include http://chat.stackoverflow.com/rooms/* | |
// @include https://chat.stackoverflow.com/rooms/* | |
// @version 3 | |
// @grant none | |
// ==/UserScript== | |
var max_one_liner = 150; | |
var max = 500; | |
var row = document.getElementById("chat-buttons"); | |
var box = document.createElement("span"); | |
row.appendChild(box); | |
function update_box(){ | |
var size = document.getElementById("input").value.length; | |
var message = " " + size + " char" + (size==1 ? "" : "s"); | |
if (size == 0){ | |
message = ""; | |
} | |
else if (size > max){ | |
message += " (Too large to submit by " + (size - max) + ")"; | |
} | |
else if (size > max_one_liner){ | |
message += " (Too large to fit starred list by " + (size - max_one_liner) + ")"; | |
} | |
box.innerHTML = message; | |
} | |
window.setInterval(update_box, 100); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment