CssUtil

css utility methods

As of 2019-12-02. See the latest version.

This script should not be not be installed directly. It is a library for other scripts to include with the meta directive // @require https://update.greatest.deepsurf.us/scripts/393202/754548/CssUtil.js

  1. // ==UserScript==
  2. // @author gaojr
  3. // @namespace https://github.com/gaojr/tampermonkey-scripts
  4. // @name:CN-zh_cn css工具类
  5. // @name CssUtil
  6. // @version 0.1
  7. // @description css utility methods
  8. // @grant GM_addStyle
  9. // ==/UserScript==
  10.  
  11. /**
  12. * 隐藏
  13. * @param selector 选择器
  14. */
  15. const hide = function (selector) {
  16. GM_addStyle(selector + ' { display: none!important;height: 0!important;width: 0!important; }');
  17. };
  18. /**
  19. * 取消浮动
  20. * @param selector 选择器
  21. */
  22. const floatNone = function (selector) {
  23. GM_addStyle(selector + ' { float: none; }');
  24. };
  25.  
  26. /**
  27. * 左右居中
  28. * @param selector 选择器
  29. */
  30. const marginCenter = function (selector) {
  31. GM_addStyle(selector + ' { margin-left: auto;margin-right: auto; }');
  32. };
  33.  
  34. /**
  35. * 左右居中
  36. * @param selector 选择器
  37. */
  38. const clearCenter = function (selector) {
  39. floatNone(selector);
  40. marginCenter(selector);
  41. // GM_addStyle(selector + ' { float: none;margin-left: auto;margin-right: auto; }');
  42. };