Permalink
Browse files

Initial Commit

  • Loading branch information...
0 parents commit da5fca51c769402d76b870b401b5f213844785f3 @markelliot committed Jun 29, 2011
Showing with 35 additions and 0 deletions.
  1. +4 −0 README.md
  2. +31 −0 SOTabRemover.user.js
4 README.md
@@ -0,0 +1,4 @@
+StackOverflow Edit Context Tab Remover
+--------------------------------------
+
+Adds a simple button (\t) to stip tabs from the post material for easier editing. The button applies only to the edit context.
31 SOTabRemover.user.js
@@ -0,0 +1,31 @@
+// ==UserScript==
+// @name StackOverflow Edit Context Tab Remover
+// @author Mark Elliot
+// @description Adds a button in the SO edit context to replace tab literals (\t) with 4 spaces
+// @include http://stackoverflow.com/posts/*/edit*
+// @match http://stackoverflow.com/posts/*/edit*
+// ==/UserScript==
+
+// This work is licensed under the Creative Commons Attribution 3.0 Unported License.
+// To view a copy of this license, visit http://creativecommons.org/licenses/by/3.0/.
+
+function with_jquery(f) {
+ var script = document.createElement("script");
+ script.type = "text/javascript";
+ script.textContent = "(" + f.toString() + ")(jQuery)";
+ document.body.appendChild(script);
+};
+
+with_jquery(function($){
+
+ $(function(){
+ $('ul#wmd-button-row li:last')
+ .before('<li class="wmd-button" id="fix-tabs" style="left: 400px; font-family: monospace; padding-top: 3px; font-size: 11px; hover:">\\t</li>')
+ .before('<li class="wmd-spacer" style="left: 375px;"></li>');
+
+ $('li#fix-tabs').click(function(){
+ $('textarea#wmd-input.processed').val($('textarea#wmd-input.processed').text().replace(/\t/g, ' '));
+ });
+ });
+
+});

0 comments on commit da5fca5

Please sign in to comment.