Last active
April 22, 2024 08:08
-
-
Save abhijithvijayan/46a9dc8248b26c68f5241d16fb6bee96 to your computer and use it in GitHub Desktop.
Rent Receipt Sanitizer for https://cleartax.in/save/rent. Run the comment https://gist.github.com/abhijithvijayan/46a9dc8248b26c68f5241d16fb6bee96?permalink_comment_id=4492263#gistcomment-4492263
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For https://cleartax.in/save/rent | |
// date of repayment against the receipt number | |
var dateOfPayments = { | |
1: "<DATE>", | |
2: "<DATE>", | |
3: "<DATE>", | |
4: "<DATE>", | |
5: "<DATE>", | |
6: "<DATE>", | |
7: "<DATE>", | |
8: "<DATE>", | |
9: "<DATE>", | |
10: "<DATE>", | |
11: "<DATE>", | |
12: "<DATE>" | |
}; | |
function receiptCleanser(dateOfPayments = {}) { | |
// removing watermark | |
[...document.querySelectorAll("a[href='/save/rent']")].forEach((x) => x.parentNode?.remove()); | |
// removing month string from receipt heading | |
[...document.querySelectorAll("strong")].filter((t) => t.textContent == "RENT RECEIPT").forEach((t) => t.parentNode?.children?.[1]?.remove()); | |
// make Pan -> PAN | |
[...document.querySelectorAll("strong")].filter((t) => t.textContent.includes("Pan")).forEach((t) => t.textContent = t.textContent.replace("Pan", "PAN")); | |
// removing future provisional watermark | |
[...document.querySelectorAll("span")].filter((t) => t.textContent == "Provisional").forEach((t) => t.parentNode?.remove()); | |
// replacing date of receipt with the actual payment date | |
[...document.querySelectorAll("p")].filter((t) => t.textContent.startsWith("Receipt No:")).forEach((t) => { | |
let receiptNumber = Number(t.textContent.match(/[0-9]+/)[0]); | |
let date = t.parentNode?.children?.[1]?.textContent; | |
if (typeof receiptNumber === "number" && dateOfPayments[receiptNumber] && typeof date === "string" && date.startsWith("Date")) { | |
t.parentNode.children[1].textContent = `Date: ${dateOfPayments[receiptNumber]}`; | |
} | |
}) | |
} |
Author
abhijithvijayan
commented
Mar 5, 2023
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment