IThome Fix

去除「IT之家」博客版信息流广告

当前为 2023-12-12 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name IThome Fix
  3. // @namespace http://your-namespace.com
  4. // @version 1.0
  5. // @description 去除「IT之家」博客版信息流广告
  6. // @author https://blog.tongmingzhi.com
  7. // @match https://www.ithome.com/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. // Function to set rounded images with proportional height
  15. function setRoundedImages() {
  16. var images = document.querySelectorAll('img');
  17. images.forEach(function(image) {
  18. image.style.borderRadius = '10px';
  19. image.style.maxWidth = '400px';
  20. image.style.height = 'auto';
  21. });
  22. }
  23.  
  24. // Function to remove ads
  25. function removeAds() {
  26. document.querySelectorAll('div.bb.clearfix > div.fl > ul.bl > li').forEach(function(element) {
  27. if (element.querySelector('div.c > div.m:empty')) {
  28. element.remove();
  29. }
  30. });
  31. }
  32.  
  33. // Wait for the page to fully load
  34. window.addEventListener('load', function() {
  35. // Execute both functions
  36. setRoundedImages();
  37. removeAds();
  38. });
  39. })();