CSS rule finder

try to take over the world!

当前为 2020-01-10 提交的版本,查看 最新版本

此脚本不应直接安装。它是供其他脚本使用的外部库,要使用该库请加入元指令 // @require https://update.cn-greasyfork.org/scripts/394970/764621/CSS%20rule%20finder.js

  1. // ==UserScript==
  2. // @name CSS rule finder
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description try to take over the world!
  6. // @author You
  7. // @match http://*/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. function css(el) {
  12. var sheets = document.styleSheets, ret = [];
  13. el.matches = el.matches || el.webkitMatchesSelector || el.mozMatchesSelector || el.msMatchesSelector || el.oMatchesSelector;
  14. for (var i in sheets) {
  15. var rules = sheets[i].rules || sheets[i].cssRules;
  16. for (var r in rules) {
  17. if (el.matches(rules[r].selectorText)) {
  18. ret.push(rules[r].cssText);
  19. }
  20. }
  21. }
  22. return ret;
  23. }