Skip to content

Instantly share code, notes, and snippets.

@codebylove
Created November 30, 2016 11:00
Show Gist options
  • Select an option

  • Save codebylove/625fdee2048c4a8debd3c6b7d37b3776 to your computer and use it in GitHub Desktop.

Select an option

Save codebylove/625fdee2048c4a8debd3c6b7d37b3776 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Change Editor Style
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match http://m.shoplex.cn/phriction/edit/*
// @grant none
// @require http://code.jquery.com/jquery-latest.js
// ==/UserScript==
(function() {
'use strict';
// Your code here...
$('.phui-two-column-content.phui-two-column-footer').append('<div style="clear: both">');
$('.phui-box.phui-box-border.phui-object-box.mlt.mll.mlr.phui-box-blue-property').css({'float':'left','min-width':'50%'});
$('.phui-remarkup-preview').css({'float':'left','min-width':'49%'});
$('.aphront-form-label').css({'width':'auto'});
$('.aphront-form-error.aphront-form-required').css({'width':'auto'});
$('.aphront-form-input').before('<br><br>').css({'margin-left': '0', 'width':'100%'});
//$('#document-textarea').css({'height':'100%'});
(function($) {
// jQuery plugin definition
$.fn.TextAreaExpander = function(minHeight, maxHeight) {
console.log('helo');
//var hCheck = !($.browser.msie || $.browser.opera);
var hCheck = false;
// resize a textarea
function ResizeTextarea(e) {
// event or initialize element?
e = e.target || e;
// find content length and box width
var vlen = e.value.length, ewidth = e.offsetWidth;
if (vlen != e.valLength || ewidth != e.boxWidth) {
if (hCheck && (vlen < e.valLength || ewidth != e.boxWidth)) e.style.height = "0px";
var h = Math.max(e.expandMin, Math.min(e.scrollHeight, e.expandMax));
e.style.overflow = (e.scrollHeight > h ? "auto" : "hidden");
e.style.height = h + "px";
e.valLength = vlen;
e.boxWidth = ewidth;
}
return true;
};
// initialize
this.each(function() {
// is a textarea?
if (this.nodeName.toLowerCase() != "textarea") return;
// set height restrictions
var p = this.className.match(/expand(\d+)\-*(\d+)*/i);
this.expandMin = minHeight || (p ? parseInt('0'+p[1], 10) : 0);
this.expandMax = maxHeight || (p ? parseInt('0'+p[2], 10) : 99999);
// initial resize
ResizeTextarea(this);
// zero vertical padding and add events
if (!this.Initialized) {
this.Initialized = true;
$(this).css("padding-top", 0).css("padding-bottom", 0);
$(this).bind("keyup", ResizeTextarea).bind("focus", ResizeTextarea);
}
});
return this;
};
})(jQuery);
// initialize all expanding textareas
jQuery(document).ready(function() {
jQuery("textarea[class*=expand]").TextAreaExpander();
});
$('#document-textarea').TextAreaExpander();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment