Skip to content

Instantly share code, notes, and snippets.

@metaodi
Created November 10, 2015 08:13
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 metaodi/0f74006d10ed67dd5697 to your computer and use it in GitHub Desktop.
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)
// ==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