Created
November 10, 2015 08:13
-
-
Save metaodi/0f74006d10ed67dd5697 to your computer and use it in GitHub Desktop.
Fix tab bug of GitLab/Chromium 45 (https://gitlab.com/gitlab-org/gitlab-ce/issues/3220)
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 Tabs to spaces for GitLab | |
// @namespace http://liip.ch/ | |
// @version 0.1 | |
// @description Fix tab bug of GitLab/Chromium 45 (https://gitlab.com/gitlab-org/gitlab-ce/issues/3220) | |
// @author Odi | |
// @match https://gitlab.liip.ch/* | |
// @grant none | |
// ==/UserScript== | |
/* jshint -W097 */ | |
'use strict'; | |
// Your code here... | |
$(function() { | |
var replaceTabsWithSpaces = function(lines) { | |
$.each( | |
lines, | |
function(line, elem) { | |
var new_html = $(elem).html().replace(/\t/g, ' '); | |
console.log(new_html); | |
$(elem).html(new_html); | |
} | |
); | |
} | |
var replaceOnPage = function() { | |
replaceTabsWithSpaces($('.line_holder')); | |
replaceTabsWithSpaces($('.line')); | |
} | |
var new_title = $('.title').html() + "<a id='switch-tabs-to-spaces' style='color:blue; font-size: 0.7em; cursor: pointer;'>[switch tabs to spaces]</a>"; | |
$('.title').html(new_title); | |
$('#switch-tabs-to-spaces').on('click', replaceOnPage); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment