Skip to content

Instantly share code, notes, and snippets.

@dest4590
Last active June 9, 2024 18:04
Show Gist options
  • Save dest4590/a3fb34fd952bdc42270d8f6272142ccf to your computer and use it in GitHub Desktop.
Save dest4590/a3fb34fd952bdc42270d8f6272142ccf to your computer and use it in GitHub Desktop.
Tampermonkey tonviewer patches

A simple script that removes scam transactions (may be false detection).

Tampermonkey script, just click on "Create new script", and paste text below:

// ==UserScript==
// @name         Tonviewer improvements
// @namespace    https://tonviewer.com/
// @version      2024-06-09
// @description  some improvements for tonviewer
// @author       You
// @match        https://tonviewer.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=tonviewer.com
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    var wait = (ms) => new Promise(resolve => setTimeout(resolve, ms));

    var enabled_icon = '<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="#e8eaed"><path d="M281.5-243.5q-98.54 0-167.52-68.97T45-479.97q0-98.53 68.98-167.53t167.52-69h397q98.54 0 167.52 68.97T915-480.03q0 98.53-68.98 167.53t-167.52 69h-397Zm0-57.5h396.86q74.97 0 127.05-52.06 52.09-52.06 52.09-127T805.41-607q-52.08-52-127.05-52H281.5q-74.5 0-126.75 52.06t-52.25 127q0 74.94 52.25 126.94t126.75 52Zm397.94-81q40.81 0 69.44-28.57 28.62-28.56 28.62-69.37t-28.57-69.44Q720.37-578 679.56-578t-69.43 28.57q-28.63 28.56-28.63 69.37t28.57 69.43Q638.63-382 679.44-382ZM480-480Z"/></svg>';

    var disabled_icon = '<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="#e8eaed"><path d="M283-247q-97.08 0-165.04-67.94T50-479.94Q50-577 117.96-645T283-713h394q97.08 0 165.04 67.94t67.96 165Q910-383 842.04-315T677-247H283Zm0-75h394q65.5 0 111.75-46.25T835-480q0-65.5-46.25-111.75T677-638H283q-65.5 0-111.75 46.25T125-480q0 65.5 46.25 111.75T283-322Zm0-44q47.5 0 80.75-33.25T397-480q0-47.5-33.25-80.75T283-594q-47.5 0-80.75 33.25T169-480q0 47.5 33.25 80.75T283-366Zm197-114Z"/></svg>';

    async function main() {
        const parentDiv = document.createElement('div');
        parentDiv.className = 'a1prxqnb';

        document.querySelector('#__next > div > div.h1klfjoy > div > div > div.bggx7el').appendChild(parentDiv);

        const div = document.createElement('div');
        div.className = 'i1cyemmh icon-content';
        div.style.setProperty('--size', '24px');
        div.style.setProperty('--icon-size', '24px');
        div.style.setProperty('--fill-color', 'var(--foregroundSecondary)');

        if (localStorage.getItem('enable_patches') == '1') {
            div.innerHTML = enabled_icon;
            console.log("on icon")
        }
        else if (localStorage.getItem('enable_patches') == '0') {
            div.innerHTML = disabled_icon;
            console.log("disabled icon")
        }

        parentDiv.appendChild(div);

        parentDiv.onclick = () => {
            if (localStorage.getItem('enable_patches') == '1') {
                localStorage.setItem('enable_patches', '0')
                location.reload()
            }
            else if (localStorage.getItem('enable_patches') == '0') {
                localStorage.setItem('enable_patches', '1')
                location.reload()
            }
        }


        if (localStorage.getItem('enable_patches') == null) {
            localStorage.setItem('enable_patches', '1')
        }

        if (localStorage.getItem('enable_patches') == '1') {
            while (true) {
                Array.from(document.getElementsByClassName("l1gmfwv5 nygz236 a1cosnym")).forEach((e) => {
                    if (e.innerText == '+ 0 TON') {
                        const line = e.parentNode.parentNode
                        if (line.getElementsByClassName('bdtytpm nygz236 a1kyw8os')[0].innerText.includes("Claim")) {
                            console.log("Removed", line)
                            line.parentNode.parentNode.parentNode.parentNode.remove()
                        }
                    }
                });
                await wait(3500);
            }
        }
    }

    main();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment