您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

contentScript.js 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. window.onload = () => {
  2. chrome.storage.sync.get([ "matchingPatterns", "exclusionPatterns", "mode" ],
  3. (result) => {
  4. killStickyIfMatch(result);
  5. });
  6. };
  7. function killStickyIfMatch(result) {
  8. if (typeof result.matchingPatterns == "undefined") return;
  9. var killSticky = false;
  10. let matchingPatterns = result.mode == "whitelist" ?
  11. [ ".*" ] :
  12. result.matchingPatterns.split("\n");
  13. for (let pattern of matchingPatterns) {
  14. if (location.href.match(new RegExp(pattern))) {
  15. killSticky = true;
  16. break;
  17. }
  18. }
  19. let exclusionPatterns = (typeof result.exclusionPatterns != "undefined" &&
  20. result.exclusionPatterns != "") ?
  21. result.exclusionPatterns.split("\n") :
  22. [ ];
  23. for (let pattern of exclusionPatterns) {
  24. if (location.href.match(new RegExp(pattern))) {
  25. killSticky = false;
  26. break;
  27. }
  28. }
  29. if (!killSticky) return;
  30. console.log("Killing all stickies!");
  31. document.querySelectorAll('body *').forEach(element => {
  32. if (getComputedStyle(element).position === 'fixed' ||
  33. getComputedStyle(element).position === 'sticky') {
  34. element.remove();
  35. }
  36. });
  37. }