CssUtil

css utility methods

此脚本不应直接安装,它是一个供其他脚本使用的外部库。如果您需要使用该库,请在脚本元属性加入:// @require https://update.cn-greasyfork.org/scripts/393202/1067207/CssUtil.js

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