This project automates the process of capturing a high-quality screenshot of a TryHackMe profile badge and updating it in a GitHub repository every 12 hours using GitHub Actions.
- Uses Puppeteer to capture a high-resolution screenshot of the TryHackMe badge.
- Automates the update process with a GitHub Action.
- Runs every 12 hours via a scheduled cron job.
Ensure you have the following installed:
- Node.js (Version 18 recommended)
- Puppeteer
- Dependencies required by Puppeteer:
sudo apt-get install -y libnss3 libxss1 fonts-liberation libatk1.0-0 \ libatk-bridge2.0-0 libcups2 libdrm2 libgbm1 libnspr4 libxcomposite1 \ libxdamage1 libxrandr2 libxtst6 xdg-utils
-
Clone this repository:
git clone https://github.com/yourusername/yourrepository.git cd yourrepository
-
Install Node.js dependencies:
npm install puppeteer
-
Create a new file named
generateBadge.js
and paste the following script:const puppeteer = require('puppeteer'); (async () => { try { const browser = await puppeteer.launch({ args: ['--no-sandbox', '--disable-setuid-sandbox'], }); const page = await browser.newPage(); await page.setViewport({ width: 1920, height: 1080, deviceScaleFactor: 2, }); const url = 'https://tryhackme.com/api/v2/badges/public-profile?userPublicId=3153096'; await page.goto(url, { waitUntil: 'networkidle2' }); const badgeSelector = '#thm-badge'; await page.waitForSelector(badgeSelector); await page.addStyleTag({ content: '#thm-badge { transform: scale(1.5); transform-origin: top left; }', }); const badgeElement = await page.$(badgeSelector); if (badgeElement) { await badgeElement.screenshot({ path: 'tryhackme-badge-high-quality.png' }); console.log('High-quality screenshot saved as tryhackme-badge-high-quality.png'); } else { console.log('Badge element not found!'); } await browser.close(); } catch (error) { console.error('Error generating screenshot:', error); } })();
-
Run the script manually to test it:
node generateBadge.js
This should generate a
tryhackme-badge-high-quality.png
file. -
Move the generated image to the
assets/
folder:mv tryhackme-badge-high-quality.png assets/
To automate the badge update process, create a GitHub Action workflow:
-
Inside your repository, navigate to
.github/workflows/
(create these folders if they don't exist). -
Create a new file named
update_badge.yml
and paste the following content:name: Update TryHackMe Badge on: schedule: - cron: "0 */12 * * *" # Runs every 12 hours jobs: update-badge: runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v3 - name: Set up Node.js uses: actions/setup-node@v3 with: node-version: "18" - name: Install Puppeteer dependencies run: sudo apt-get install -y libnss3 libxss1 fonts-liberation libatk1.0-0 libatk-bridge2.0-0 libcups2 libdrm2 libgbm1 libnspr4 libxcomposite1 libxdamage1 libxrandr2 libxtst6 xdg-utils - name: Install Puppeteer run: npm install puppeteer - name: Generate TryHackMe badge run: node generateBadge.js - name: Move badge to assets folder run: mv tryhackme-badge-high-quality.png assets/tryhackme-badge-high-quality.png - name: Commit and push changes run: | git config --global user.name "github-actions[bot]" git config --global user.email "github-actions[bot]@users.noreply.github.com" git add assets/tryhackme-badge-high-quality.png git commit -m "Update TryHackMe badge" git push
- Commit and push your changes to GitHub:
git add . git commit -m "Added TryHackMe badge automation" git push origin main
- The GitHub Action will now run automatically every 12 hours to update your badge.
This is a Go-based tool that checks whether a given Medium article URL is a premium (member-only) story. It uses the chromedp
package to automate a headless Chrome browser, navigate to the provided URL, and determine if the article is premium by checking for specific indicators such as "Member-only story" text or a golden star icon.
-
Install Go: Ensure you have Go installed on your system. You can download it from here.
-
Clone the Repository:
git clone https://github.com/yourusername/medium-premium-checker.git cd medium-premium-checker
-
Install Dependencies:
go mod tidy
-
Build the Tool:
go build -o medium-premium-checker
Run the tool from the command line by providing a Medium article URL as an argument:
./medium-premium-checker https://medium.com/your-article-url
-
If the article is premium:
🔒 https://medium.com/your-article-url is PREMIUM
-
If the article is not premium:
🔒 https://medium.com/your-article-url is NOT premium
This is a Node.js-based tool that checks whether a given Medium article URL is a premium (member-only) story. It uses the puppeteer
package to automate a headless Chrome browser, navigate to the provided URL, and determine if the article is premium by checking for specific indicators such as "Member-only story" text or a golden star icon.
-
Install Node.js: Ensure you have Node.js installed on your system. You can download it from here.
-
Clone the Repository:
git clone https://github.com/yourusername/medium-premium-checker-puppeteer.git cd medium-premium-checker-puppeteer
-
Install Dependencies:
npm install puppeteer
Run the tool from the command line by providing a Medium article URL as an argument:
node index.js https://medium.com/your-article-url
-
If the article is premium:
🔒 https://medium.com/your-article-url is PREMIUM
-
If the article is not premium:
🔒 https://medium.com/your-article-url is NOT premium