Skip to content

Instantly share code, notes, and snippets.

@sam2332
Created April 8, 2022 14:46
Show Gist options
  • Save sam2332/cba94e278f48fa7e6bc3d51eaaf864e5 to your computer and use it in GitHub Desktop.
Save sam2332/cba94e278f48fa7e6bc3d51eaaf864e5 to your computer and use it in GitHub Desktop.
Make fun of everything in redmine support
// ==UserScript==
// @name Redmine - SpongeMock
// @match https://*.*.*/issues/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
var letters = "abcdefghijklmnopqrstuvwxyz"
function mocking(text){
let out = "";
for (let letter_index = 0; letter_index < text.length; letter_index++){
if (letters.indexOf(text[letter_index]) ==-1){
out+=text[letter_index]
}else{
if (Math.random()*100 >=50){
out+=text[letter_index].toLowerCase();
}else{
out+=text[letter_index].toUpperCase()
}
}
}
return out
}
function replaceAll(str, find, replace) {
return str.replace(new RegExp(find, 'g'), replace);
}
function nl2br(text){
return replaceAll(text,"\n","<br>")
}
let subject = $('.subject');
subject.html(nl2br(mocking(subject.text())))
let users = $('.user');
for (let user_index = 0; user_index < users.length; user_index++)
{
let user = $(users[user_index]);
user.html(nl2br(mocking(user.text())))
}
let description = $('.description .wiki')
description.html(nl2br(mocking(description.text())))
$('.journal').each(function(index,ele){
ele = $(ele)
let id = ele.prop('id').split('-')[1]
if (ele.hasClass('has-notes')){
let notes = $('#journal-'+id+'-notes')
notes.html(nl2br(mocking(notes.text())))
}
})
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment