Skip to content

Instantly share code, notes, and snippets.

@marineko
Created December 10, 2019 07:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marineko/990fe8e51965b6effc9820cd757ce72c to your computer and use it in GitHub Desktop.
Save marineko/990fe8e51965b6effc9820cd757ce72c to your computer and use it in GitHub Desktop.
var observer = new MutationObserver(function (mutations) {
mutations.forEach(function (mutation) {
if (mutation.target.className === "ms-List-cell" || mutation.target.className === "ms-List-surface") {
var customBody = document.getElementsByClassName('customBody');
for (var i = 0, len = customBody.length | 0; i < len; i = i + 1 | 0) {
var ret;
customBody[i].innerHTML = customBody[i].textContent;
ret = truncate(customBody[i].textContent, 100);
customBody[i].innerText = ret;
}
}
});
});
var config = {
subtree: true,
childList: true
};
observer.observe(document.documentElement, config);
function truncate(str, len) {
return str.length <= len ? str : str.substr(0, len) + "...";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment