{"id":30594876,"url":"https://github.com/pasanlaksitha/iit-gmail-microsite-filter","last_synced_at":"2025-08-29T20:32:52.575Z","repository":{"id":307448709,"uuid":"957749879","full_name":"Pasanlaksitha/iit-gmail-microsite-filter","owner":"Pasanlaksitha","description":"A Gmail filter script for IIT students to automatically label and archive emails containing sites.google.com links.","archived":false,"fork":false,"pushed_at":"2025-07-31T07:44:15.000Z","size":1966,"stargazers_count":7,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-31T11:19:04.386Z","etag":null,"topics":["apps-script","email-filter","gmail","iit","spam-filtering"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Pasanlaksitha.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-03-31T04:03:43.000Z","updated_at":"2025-07-31T07:44:19.000Z","dependencies_parsed_at":"2025-07-31T11:35:40.950Z","dependency_job_id":null,"html_url":"https://github.com/Pasanlaksitha/iit-gmail-microsite-filter","commit_stats":null,"previous_names":["pasanlaksitha/iit-gmail-microsite-filter"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/Pasanlaksitha/iit-gmail-microsite-filter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pasanlaksitha%2Fiit-gmail-microsite-filter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pasanlaksitha%2Fiit-gmail-microsite-filter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pasanlaksitha%2Fiit-gmail-microsite-filter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pasanlaksitha%2Fiit-gmail-microsite-filter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Pasanlaksitha","download_url":"https://codeload.github.com/Pasanlaksitha/iit-gmail-microsite-filter/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pasanlaksitha%2Fiit-gmail-microsite-filter/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272758402,"owners_count":24988239,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-29T02:00:10.610Z","response_time":87,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["apps-script","email-filter","gmail","iit","spam-filtering"],"created_at":"2025-08-29T20:32:51.874Z","updated_at":"2025-08-29T20:32:52.569Z","avatar_url":"https://github.com/Pasanlaksitha.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 📧 IIT Gmail Microsite SPAM Filter (Google Apps Script)\n\n![Made for IIT Students](https://img.shields.io/badge/IIT-Student%20Tool-blue)\n![License](https://img.shields.io/badge/License-MIT-green)\n\nThis Google Apps Script filters your Gmail Inbox to find emails that contain links to `sites.google.com`, even if they are **masked behind custom text** like \"Click Here\". It then:\n\n- Labels those emails under a folder called **Microsite**\n- Archives them to remove from the **Inbox**\n- Keeps your inbox clean from unwanted promotional website links\n\n---\n\n## 🎓 Who Is This For?\n\nThis script is made specifically for **IIT (Institute of Information Technology)** students who want to automatically filter out emails that promote personal websites using Google Sites. No coding knowledge is required — just copy, paste, and set it up!\n\n## 🚀 What It Does\n\n✅ Detects:\n\n- Visible links like `https://sites.google.com/...`\n- Masked links like `[Click Here](https://sites.google.com/view/project/home)`\n- Raw URLs embedded anywhere in email content\n\n✅ Automatically:\n\n- Labels the email as `Microsite`\n- Moves it out of the Inbox (archived)\n- Runs on all Inbox emails received in the last **30 days**\n\n---\n\n## 🛠️ How to Install and Use\n\n\u003e You don't need to deploy anything. Just follow the steps below.\n\n---\n\n### 🔧 Step 1: Open Google Apps Script\n\n1. Go to [https://script.google.com](https://script.google.com)\n2. Click **`+ New project`**\n3. Name your project (e.g., `Microsite Link Filter`)\n\n---\n\n### 📋 Step 2: Copy and Paste the Script\n\nReplace the default `Code.gs` content with the code below:\n\n```javascript\nfunction detectAllGoogleSiteLinks() {\n  const threads = GmailApp.search(\"in:inbox newer_than:30d\"); // configure the dates you need to scrap\n  const label = GmailApp.createLabel(\"Microsite\"); // Label Folder change if desired\n\n  threads.forEach((thread) =\u003e {\n    const messages = thread.getMessages();\n    messages.forEach((message) =\u003e {\n      const htmlBody = message.getBody();\n\n      // Check direct plain-text match\n      if (htmlBody.includes(\"sites.google.com\")) {\n        applyMicrositeLabelAndArchive(thread, label);\n        Logger.log(\n          \"Found plain sites.google.com link in: \" + message.getSubject()\n        );\n        return;\n      }\n\n      // Check masked \u003ca href\u003e links\n      const hrefRegex =\n        /\u003ca\\s[^\u003e]*?href=[\"'](https:\\/\\/sites\\.google\\.com\\/[^\"']+)[\"'][^\u003e]*?\u003e.*?\u003c\\/a\u003e/gi;\n      let match;\n      while ((match = hrefRegex.exec(htmlBody)) !== null) {\n        const foundUrl = match[1];\n        applyMicrositeLabelAndArchive(thread, label);\n        Logger.log(\n          \"Found masked link: \" + foundUrl + \" in: \" + message.getSubject()\n        );\n        return;\n      }\n\n      // Fallback: check raw URLs in the body\n      const rawLinkRegex = /(https:\\/\\/sites\\.google\\.com\\/[^\\s\"'\u003c\u003e]+)/gi;\n      const rawMatches = htmlBody.match(rawLinkRegex);\n      if (rawMatches \u0026\u0026 rawMatches.length \u003e 0) {\n        applyMicrositeLabelAndArchive(thread, label);\n        Logger.log(\n          \"Found raw link(s): \" +\n            rawMatches.join(\", \") +\n            \" in: \" +\n            message.getSubject()\n        );\n        return;\n      }\n    });\n  });\n}\n\n// Label thread and remove from Inbox\nfunction applyMicrositeLabelAndArchive(thread, label) {\n  const existingLabels = thread.getLabels().map((l) =\u003e l.getName());\n  if (!existingLabels.includes(label.getName())) {\n    thread.addLabel(label);\n  }\n  thread.moveToArchive(); // removes it from Inbox\n}\n```\n\n---\n\n### ▶️ Step 3: Run the Script Once\n\n1. Click the `▶️ Run` button (in the top toolbar)\n2. It will prompt you for authorization — allow permissions for Gmail\n3. The script will scan your Inbox for `sites.google.com` links and start filtering\n\n![gif1.gif](media/gif1.gif)\n\n## ![Screenshot1.png](media/Screenshot1.png)\n\n### ⏰ Step 4: Schedule It to Run Automatically (Optional)\n\n1. In the Apps Script editor, click the **clock icon** (Triggers)\n2. Click `+ Add Trigger`\n3. Configure:\n   - Function: `detectAllGoogleSiteLinks`\n   - Event source: `Time-driven`\n   - Type: `Day timer`\n   - Time of day: e.g., `7:00am to 8:00am`\n\nThis will automatically run the filter every morning.\n\n![gif2.gif](media/gif2.gif)\n\n---\n\n## 📂 Where Do Filtered Emails Go?\n\n- They are moved out of your Inbox\n- You can find them under the **`Microsite`** label in Gmail\n\n## ![Screenshot2.png](media/Screenshot2.png)\n\n## 📌 Notes\n\n- You can change `\"Microsite\"` to any label name you prefer\n- You can update `newer_than:30d` to scan a different time range (like `10d` or `1d`)\n- This script works only for the emails in your own Gmail account\n\n---\n\n## ❌ To Stop It\n\nIf you no longer want to run the filter:\n\n- Go to the **Triggers** tab and delete the trigger\n- Or just delete the script project from your Apps Script dashboard\n\n---\n\n## ✅ Requirements\n\n- your IIT Gmail Account eg: `spammer.2023233@iit.ac.lk`\n\n---\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpasanlaksitha%2Fiit-gmail-microsite-filter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpasanlaksitha%2Fiit-gmail-microsite-filter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpasanlaksitha%2Fiit-gmail-microsite-filter/lists"}