Skip to content

Instantly share code, notes, and snippets.

View OJ7's full-sized avatar
🦁
Woof!

Omair OJ7

🦁
Woof!
View GitHub Profile
@OJ7
OJ7 / xbgp-dekudeals.js
Created June 10, 2020 17:30
Parse Xbox GamePass availability and display on DekuDeals
/* XBOX GAME PASS LIST PAGE
https://www.xbox.com/en-US/xbox-game-pass/games
*/
// Scrape XBGP Data (run on each page)
var titles = [...document.getElementsByClassName("x1GameName")].map(a => a.innerText.replace(/( - Windows 10 Edition)|( - Xbox One Edition)|( - Windows 10)|( for Windows 10)|( \(Windows\))/, ''));
var availability = [...[...[...document.getElementsByClassName("availability")]].map(a => a.getElementsByClassName("c-glyph"))].map(a => [...a].map(b => b.ariaLabel));
var gpMap = JSON.parse(window.localStorage.getItem("xbgp", gpMap) || '{}');
for(var i = 0; i < titles.length; i++) {
@OJ7
OJ7 / web-whatsapp.css
Last active June 10, 2020 17:35
Blur WhatsApp Web message preview (left-hand side chat list)
// Persistently apply using an extension like Styler Pro
// https://chrome.google.com/webstore/detail/styler-pro/hbhkfnpodhdcaophahpkiflechaoddoi
// Blur text in message preview
._3tBW6 {
color: transparent;
text-shadow: 0 0 4px rgba(0,0,0,0.5);
}
// Blur emojis in message preview
@OJ7
OJ7 / extractText.js
Last active December 5, 2019 21:53
Extract Article Texts
// Scripts to extract the text of article body for various websites
// gematsu.com
[...[...document.getElementsByClassName("post_content")][0].children].map(p => p.innerText).join('\n\n')
// venturebeat.com
[...[...document.getElementsByClassName("article-content")][0].children].map(p => p.innerText).join('\n\n')
// ign.com (partially working, some texts are not enclosed in any tags/elements and are not caught by below)
[...[...document.getElementsByClassName("article-page")][0].children].map(p => p.innerText).join('\n\n')
@OJ7
OJ7 / dummy-migration.html
Created October 15, 2019 21:56
Migrate Android IndexedDB from Ionic 3 to Ionic 4
<!-- This file goes in 'src/assets/migration.html' -->
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Migration Example</title>
<base href="/" />
@OJ7
OJ7 / automations.yaml
Last active March 21, 2024 19:08
Automate Playing Adhan on Google Home (using Home Assistant)
# Automation for Dhuhr, Asr, Maghrib, and Isha Adhan
- action:
- alias: ''
data:
entity_id: media_player.family_room_speaker # replace with your Google Home's id
media_content_id: https://www.youtube.com/watch?v=ADLO-Hm_nCQ # replace with your choice of Adhan
media_content_type: audio/youtube
service: media_extractor.play_media
- data:
entity_id: media_player.family_room_speaker # replace with your Google Home's id
@OJ7
OJ7 / salat_times.py
Last active September 14, 2021 17:56
Home Assistant Islamic Prayer Times
import json
from datetime import datetime, timedelta
try:
from urllib.request import Request, urlopen # Python 3
except ImportError:
from urllib2 import Request, urlopen # Python 2
def convertTime(salatTime, offset):
salatTime = datetime.strptime(salatTime, '%I:%M %p')
@OJ7
OJ7 / OpenFileWithSublimeText3.bat
Created April 4, 2016 17:57
Add "Open with Sublime Text 3" to Windows Explorer Context Menu (only files)
@echo off
SET st3fqfn=C:\Program Files\Sublime Text 3\sublime_text.exe
rem add it for all file types
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 3" /t REG_SZ /v "" /d "Open with Sublime Text 3" /f
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 3" /t REG_EXPAND_SZ /v "Icon" /d "%st3fqfn%,0" /f
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 3\command" /t REG_SZ /v "" /d "%st3fqfn% \"%%1\"" /f
pause