Suspicious Website TLD Blocker

Block websites that use domain extensions often associated with spam, scams, and malware.

安装此脚本
作者推荐脚本

您可能也喜欢Scam Site Blocker

安装此脚本
  1. // ==UserScript==
  2. // @name Suspicious Website TLD Blocker
  3. // @namespace blockSuspiciousTLDs
  4. // @version 1.5
  5. // @description Block websites that use domain extensions often associated with spam, scams, and malware.
  6. // @author Kai Krause <kaikrause95@gmail.com>
  7. // @include *
  8. // @grant GM_setValue
  9. // @grant GM_getValue
  10. // @run-at document-start
  11. // ==/UserScript==
  12.  
  13. // TODO(?): Region-specific TLD blocking. For example, blocking of Russian or Chinese TLDs.
  14. // TODO(?): Whitelist of government-owned .us domains, and blocking of all other .us domains.
  15.  
  16. var websiteTerms = location.hostname.split(".");
  17. var currentURL = websiteTerms[websiteTerms.length-2] + "." + websiteTerms[websiteTerms.length-1]
  18. var thisTLD = websiteTerms[websiteTerms.length-1]
  19.  
  20. // whitelist
  21. var exclusions = ["abc.xyz"];
  22. if (exclusions.indexOf(currentURL) > -1) return;
  23.  
  24. // https://en.wikipedia.org/wiki/List_of_Internet_top-level_domains#ICANN-era_generic_top-level_domains
  25. var genericTLDs = ["academy", "accountant", "accountants", "active", "actor", "ads", "adult", "agency", "airforce", "analytics", "apartments", "app", "army", "art", "associates", "attorney", "auction", "audible", "audio", "author", "auto", "autos", "aws", "baby", "band", "bar", "barefoot", "bargains", "baseball", "basketball", "beauty", "beer", "best", "bestbuy", "bet", "bible", "bid", "bike", "bingo", "biz", "black", "blackfriday", "blockbuster", "blog", "blue", "boo", "book", "boots", "bot", "boutique", "box", "broadway", "broker", "build", "builders", "business", "buy", "buzz", "cab", "cafe", "call", "cam", "camera", "camp", "cancerresearch", "capital", "car", "cards", "care", "career", "careers", "cars", "case", "cash", "casino", "catering", "catholic", "center", "cern", "ceo", "cfd", "channel", "chat", "cheap", "christmas", "church", "cipriani", "circle", "city", "claims", "cleaning", "click", "clinic", "clothing", "cloud", "club", "coach", "codes", "coffee", "college", "community", "company", "compare", "computer", "condos", "construction", "consulting", "contact", "contractors", "cooking", "cool", "country", "coupon", "coupons", "courses", "credit", "creditcard", "cruise", "cricket", "cruises", "dad", "dance", "data", "date", "dating", "day", "deal", "deals", "degree", "delivery", "democrat", "dental", "dentist", "design", "dev", "diamonds", "diet", "digital", "direct", "directory", "discount", "diy", "docs", "doctor", "dog", "domains", "dot", "download", "drive", "duck", "earth", "eat", "education", "email", "energy", "engineer", "engineering", "enterprises", "equipment", "estate", "events", "exchange", "expert", "exposed", "express", "fail", "faith", "family", "fan", "fans", "farm", "fashion", "fast", "feedback", "film", "final", "finance", "financial", "fire", "fish", "fishing", "fit", "fitness", "flights", "florist", "flowers", "foo", "food", "foodnetwork", "football", "forsale", "forum", "foundation", "free", "frontdoor", "fun", "fund", "furniture", "fyi", "gallery", "game", "games", "garden", "gay", "gdn", "gift", "gifts", "gives", "glass", "global", "gold", "golf", "gop", "graphics", "gripe", "grocery", "group", "guide", "guitars", "guru", "hair", "hangout", "health", "healthcare", "help", "here", "hiphop", "hiv", "hockey", "holdings", "holiday", "homegoods", "homes", "homesense", "horse", "hospital", "host", "hosting", "hot", "hotels", "house", "how", "ice", "icu ", "industries", "ing", "ink", "institute", "insurance", "insure", "international", "investments", "jewelry", "jobs", "joy", "kim", "kitchen", "land", "lat", "latino", "law", "lawyer", "lease", "legal", "life", "lifeinsurance", "lighting", "like", "limited", "limo", "link", "live", "living", "loan", "loans", "locker", "lol", "lotto", "love", "luxury", "makeup", "management", "map", "market", "marketing", "markets", "mba", "med", "media", "meet", "meme", "memorial", "men", "menu", "mint", "mobi", "mobile", "mobily", "moe", "mom", "money", "monster", "mortgage", "motorcycles", "mov", "movie", "music", "name", "navy", "network", "new", "news", "ninja", "now", "observer", "off", "one", "onl", "online", "ooo", "open", "origins", "page", "partners", "parts", "party", "pay", "pet", "phone", "photo", "photography", "photos", "pics", "pictures", "pid", "pin", "pink", "pizza", "place", "plumbing", "plus", "poker", "porn", "press", "prime", "pro", "productions", "prof", "promo", "properties", "property", "protection", "pub", "qpon", "racing", "radio", "read", "realestate", "realty", "recipes", "red", "rehab", "ren", "rent", "rentals", "repair", "report", "republican", "rest", "restaurant", "review", "reviews", "rich", "rip", "rocks", "rodeo", "room", "rugby", "run", "safe", "sale", "save", "scholarships", "school", "science", "search", "secure", "security", "select", "services", "sex", "sexy", "shoes", "shop", "shopping", "show", "showtime", "silk", "singles", "site", "ski", "skin", "sky", "sling", "smile", "soccer", "social", "software", "solar", "solutions", "song", "space", "spot", "spreadbetting", "storage", "store", "stream", "studio", "study", "style", "sucks", "supplies", "supply", "support", "surf", "surgery", "systems", "talk", "tattoo", "tax", "taxi", "team", "tech", "technology", "tennis", "theater", "theatre", "tickets", "tips", "tires", "today", "tools", "top", "tours", "town", "toys", "trade", "trading", "training", "travelersinsurance", "trust", "tube", "tunes", "uconnect", "university", "vacations", "ventures", "vet", "video", "villas", "vip", "vision", "vodka", "voting", "voyage", "wang", "watch", "watches", "weather", "webcam", "website", "wed", "wedding", "whoswho", "wiki", "win", "wine", "winners", "work", "works", "world", "wow", "wtf", "xxx", "xyz", "yachts", "yoga", "you", "zero", "zone", "shouji", "tushu", "wanggou", "weibo", "xihuan", "arte", "clinique", "luxe", "maison", "moi", "rsvp", "sarl", "epost", "haus", "immobilien", "jetzt", "kaufen", "kinder", "reisen", "schule", "versicherung", "desi", "shiksha", "casa", "immo", "moda", "bom", "passagens", "gratis", "futbol", "hoteles", "juegos", "soy", "tienda", "uno", "viajes", "vuelos"];
  26.  
  27. // https://www.freenom.com/en/freeandpaiddomains.html
  28. // https://www.spamhaus.org/statistics/tlds/
  29. // https://www.symantec.com/connect/blogs/zip-urls-or-why-you-should-block-domains-tld-doesnt-have-any
  30. var badTLDs = ["pw", "gq", "cf", "ga", "ml", "tk", "xin", "zip", "ws"];
  31.  
  32. if (badTLDs.indexOf(thisTLD) > -1 || genericTLDs.indexOf(thisTLD) > -1) {
  33. var isPageIgnored = GM_getValue(location.hostname);
  34. if (!isPageIgnored || isPageIgnored != "ignored") {
  35. blockPage();
  36. }
  37. }
  38.  
  39. function blockPage() {
  40. // Stop page from loading further
  41. window.stop();
  42.  
  43. // Rewrite the page
  44. if (!document.body) {
  45. setTimeout(() => {
  46. document.body = document.createElement("body");
  47. fillPage();
  48. }, 0);
  49. }
  50. else {
  51. fillPage();
  52. }
  53. }
  54.  
  55. function fillPage() {
  56. // reset document head
  57. var head = document.getElementsByTagName('head');
  58. if (head && head[0]) {
  59. head[0].innerHTML = "<title>" + document.title + "</title>";
  60. }
  61.  
  62. // rewrite the document with itself if it already existed, to remove event listeners
  63. var old_element = document.body;
  64. var new_element = old_element.cloneNode(true);
  65. old_element.parentNode.replaceChild(new_element, old_element);
  66.  
  67. // reset styling on the body element
  68. document.body.className = "";
  69. document.body.style = "";
  70.  
  71. // rewrite the document body contents with our warning message
  72. document.body.innerHTML = "<center><h2>Suspicious Site Blocked by <a href='#' id='authorlink' style='color:#000000;'><u>Supicious TLD Blocker</u></a></h2><br /></center>";
  73. document.body.innerHTML += "<center>This website uses a non-standard domain extension and may be malicious. Go back or close this page.<br /><br /></center>";
  74. document.body.innerHTML += "<center>If you think this is an error, confirm the website address before ignoring this warning.<br /><br /></center>";
  75. document.body.innerHTML += "<center><button id='ignorePage'>Ignore Warning</button></center>";
  76. document.body.style.fontSize = "18px";
  77. document.body.style.color = "#000000";
  78. document.body.style.backgroundColor = "#f9d831";
  79. document.getElementById("ignorePage").style.padding = "6px";
  80. document.getElementById("ignorePage").addEventListener("click", ignorePage);
  81. document.getElementById("authorlink").addEventListener("click", openAuthorPage);
  82. }
  83.  
  84. function openAuthorPage() {
  85. window.open("https://gf.qytechs.cn/en/scripts/374164-suspicious-website-tld-blocker", "_blank");
  86. }
  87.  
  88. // ignore pages by domain name, handled via GM storage
  89. function ignorePage() {
  90. if (GM_setValue) {
  91. GM_setValue(location.hostname, "ignored");
  92. location.reload();
  93. }
  94. }

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址