Skip to content

Instantly share code, notes, and snippets.

@z-aki
Last active January 16, 2025 19:08
Show Gist options
  • Select an option

  • Save z-aki/2823ed966ab031e959e06e73fcf93061 to your computer and use it in GitHub Desktop.

Select an option

Save z-aki/2823ed966ab031e959e06e73fcf93061 to your computer and use it in GitHub Desktop.
Convert a Tummoc(TM) QR present in every BMTC BUS to an UPI QR code. iOS Safari supports long press on a QR to select the UPI app of choice to open it. Since directly opening upi:// link will open WhatsApp, this "QR code long press" intermediate step is needed. The url is in the format https://play.google.com/store/apps/details?id=org.transhelp.…
// ==UserScript==
// @name Tummoc(TM) QR to UPI QR Code BMTC buses Bengaluru
// @version 1.0
// @match *://play.google.com/*
// @description Convert a Tummoc(TM) QR present in every BMTC BUS to an UPI QR code. iOS Safari supports long press on a QR to select the UPI app of choice to open it. Since directly opening upi:// link will open WhatsApp, this "QR code long press" intermediate step is needed. The url is in the format https://play.google.com/store/apps/details?id=org.transhelp.bykerr&tummoc_qr=BMTC+BUS+KA51AJ7614Bangalore. The script extracts the bus number from the url KA51AJ7614, and creates a upi://pay?pa=KA51AJ7614@cnrb&pn=&cu=INR QR code.
// ==/UserScript==
/*
Convert a Tummoc(TM) QR present in every BMTC BUS to an UPI QR code.
iOS Safari supports long press on a QR to select the UPI app of
choice to open it. Since directly opening upi:// link will open
WhatsApp, this "QR code long press" intermediate step is needed.
The url is in the format https://play.google.com/store/apps/details?id=org.transhelp.bykerr&tummoc_qr=BMTC+BUS+KA51AJ7614Bangalore .
The script extracts the bus number from the url KA51AJ7614, and creates
a upi://pay?pa=KA51AJ7614@cnrb&pn=&cu=INR QR code.
1. Install https://github.com/quoid/userscripts
2. Download the JS file.
3. Scan QR, allow access to the extension to the play.google.com site.
*/
(function () {
'use strict';
var currentUrl = window.location.href;
const regex = /KA[0-9]{1,2}[A-Z]{1,2}[0-9]{1,4}/;
var busNumberMatch = currentUrl.match(regex);
if (busNumberMatch) {
var busNumber = busNumberMatch[0].replace(/[^A-Za-z0-9]/g, '');
// Construct the BHIM link
var bhimLink = `upi://pay?pa=${busNumber}@cnrb&pn=&cu=INR`;
bhimLink = encodeURIComponent(bhimLink);
window.open(`https://emn178.github.io/online-tools/qr-code/?input=${bhimLink}&type=png&size=256&padding=16&ec=Q&dot_option_type=square&dot_option_color=%23000&corners_square_option_color=%23000&corners_dot_option_color=%23000&background_option_color=%23fff&image_type=url&image_size=0.4&image_margin=0&image_show_background=0`, '_blank');
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment