Skip to content

Instantly share code, notes, and snippets.

@abhijithvijayan
Last active April 22, 2024 08:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abhijithvijayan/46a9dc8248b26c68f5241d16fb6bee96 to your computer and use it in GitHub Desktop.
Save abhijithvijayan/46a9dc8248b26c68f5241d16fb6bee96 to your computer and use it in GitHub Desktop.
// 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]}`;
}
})
}
@abhijithvijayan
Copy link
Author

abhijithvijayan commented Mar 5, 2023

(() => {
    // NOTE: update this URL if script in gist is updated
    var scriptUrl = "https://gist.githubusercontent.com/abhijithvijayan/46a9dc8248b26c68f5241d16fb6bee96/raw/f33cee33fdc535e731d28d836cee7ec72e0f9a2a/clear-tax-rent-receipt.js";
    var scriptToInject = document.createElement("script");
    // var scriptSrcURL = 'https://corsproxy.io/?' + encodeURIComponent(scriptUrl);
    var scriptSrcURL = 'https://api.codetabs.com/v1/proxy/?quest=' + encodeURIComponent(scriptUrl);

    // date of repayment against the receipt number
    var dateOfPayments = {
        1: "Apr 01 2023",
        2: "May 04 2023",
        3: "Jun 03 2023",
        4: "Jun 30 2023",
        5: "Aug 01 2023",
        6: "Sep 04 2023",
        7: "Oct 03 2023",
        8: "Nov 02 2023",
        9: "Nov 29 2023",
        10: "Jan 04 2024",
        11: "Feb 03 2024",
        12: "Mar 04 2024"
    };

    fetch(scriptSrcURL).then((res) => res.text()).then((code) => {
        scriptToInject.append(code);
        document.body.append(scriptToInject);
        console.log("call 'receiptCleanser(dateOfPayments)' for the magic!")
    })
})();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment