<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Enoch</title>
    <description>The latest articles on DEV Community by Enoch (@enochcreator).</description>
    <link>https://dev.to/enochcreator</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3896913%2F7decac92-be8f-4352-bf43-2379f5b8e13f.png</url>
      <title>DEV Community: Enoch</title>
      <link>https://dev.to/enochcreator</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/enochcreator"/>
    <language>en</language>
    <item>
      <title>How to Write an Automatic Cashback Redirect Script in JavaScript</title>
      <dc:creator>Enoch</dc:creator>
      <pubDate>Mon, 27 Apr 2026 02:54:56 +0000</pubDate>
      <link>https://dev.to/enochcreator/how-to-write-an-automatic-cashback-redirect-script-in-javascript-eni</link>
      <guid>https://dev.to/enochcreator/how-to-write-an-automatic-cashback-redirect-script-in-javascript-eni</guid>
      <description>&lt;p&gt;The way a cashback script works is simple: when you visit a shopping website, it automatically routes your session through a cashback platform, allowing you to earn a percentage of your purchase as cashback. With a simple userscript, you can automate this process on any supported site.&lt;/p&gt;

&lt;p&gt;What is a Userscript?&lt;br&gt;
A userscript is a small JavaScript program that runs in your browser, typically via extensions like Tampermonkey or Greasemonkey. It executes on specified pages after they load, and can redirect links, inject notification banners, or modify page behavior—all on the client side.&lt;/p&gt;

&lt;p&gt;Basic Idea&lt;br&gt;
When a user visits a shopping site, the script checks whether a cashback session has already been activated. If not, it redirects the user to a cashback platform (such as &lt;a href="https://www.jtmate.com/" rel="noopener noreferrer"&gt;JTMate&lt;/a&gt;), where the purchase is tracked and rewards are credited back to the user.&lt;/p&gt;

&lt;p&gt;Full Script&lt;br&gt;
Paste the following code into a new script in Tampermonkey:&lt;/p&gt;

&lt;p&gt;// ==UserScript==&lt;br&gt;
// name:         Cashback Auto Redirect&lt;br&gt;
// version:      1.0&lt;br&gt;
// description:  Earn cashback automatically via JTMate&lt;br&gt;
// match:        &lt;em&gt;://&lt;/em&gt;.amazon.com/*&lt;br&gt;
// match:        &lt;em&gt;://&lt;/em&gt;.ebay.com/*&lt;br&gt;
// ==/UserScript==&lt;/p&gt;

&lt;p&gt;(function () {&lt;br&gt;
  'use strict';&lt;/p&gt;

&lt;p&gt;const CASHBACK_PORTAL = '&lt;a href="https://jtmate.com/?ref=auto&amp;amp;url=" rel="noopener noreferrer"&gt;https://jtmate.com/?ref=auto&amp;amp;url=&lt;/a&gt;';&lt;br&gt;
  const SESSION_KEY = 'cashback_activated';&lt;/p&gt;

&lt;p&gt;// Prevent redirect loop&lt;br&gt;
  if (sessionStorage.getItem(SESSION_KEY)) return;&lt;/p&gt;

&lt;p&gt;sessionStorage.setItem(SESSION_KEY, 'true');&lt;/p&gt;

&lt;p&gt;// Redirect via cashback platform&lt;br&gt;
  const currentUrl = encodeURIComponent(window.location.href);&lt;br&gt;
  window.location.replace(CASHBACK_PORTAL + currentUrl);&lt;br&gt;
})();&lt;br&gt;
Note: In actual use, each metadata line must start with // and include the @ symbol before field names (e.g., &lt;a class="mentioned-user" href="https://dev.to/name"&gt;@name&lt;/a&gt;, &lt;a class="mentioned-user" href="https://dev.to/match"&gt;@match&lt;/a&gt;). This is the standard format required for Tampermonkey to recognize script metadata.&lt;/p&gt;

&lt;p&gt;Core Logic Explanation&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Match Target Websites&lt;br&gt;
Use the match field in the script header to specify which shopping sites the script should run on. Wildcards are supported, and you can add as many platforms as needed.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Prevent Redirect Loops&lt;br&gt;
Use sessionStorage to store a flag. Each time the script runs, it checks this flag first. If it exists, the script exits immediately to avoid infinite redirects.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Redirect to Cashback Platform&lt;br&gt;
Encode the current page URL and append it to the cashback platform link, for example:&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://jtmate.com/?ref=auto&amp;amp;url=https%3A%2F%2Fwww.amazon.com%2F" rel="noopener noreferrer"&gt;https://jtmate.com/?ref=auto&amp;amp;url=https%3A%2F%2Fwww.amazon.com%2F&lt;/a&gt;...&lt;br&gt;
After receiving the request, JTMate registers the session and redirects the user back to the original shopping page, creating a seamless experience.&lt;/p&gt;

&lt;p&gt;Installation&lt;br&gt;
Install Tampermonkey in your browser&lt;/p&gt;

&lt;p&gt;Click the extension icon → Create a new script&lt;/p&gt;

&lt;p&gt;Paste the code above (make sure to add @ symbols where needed) and save&lt;/p&gt;

&lt;p&gt;Visit any matched shopping website, and the cashback session will activate automatically&lt;/p&gt;

&lt;p&gt;Optimization Suggestions&lt;br&gt;
Expand platform support: Add more match lines to cover additional e-commerce sites&lt;/p&gt;

&lt;p&gt;Show activation notice: Inject a small banner to inform users that cashback has been activated&lt;/p&gt;

&lt;p&gt;Track data: Store activation records in localStorage to monitor cashback history&lt;/p&gt;

&lt;p&gt;Summary&lt;br&gt;
Writing a cashback userscript is an efficient way to save money during everyday online shopping. By routing sessions through a platform like &lt;a href="https://www.jtmate.com/" rel="noopener noreferrer"&gt;JTMate&lt;/a&gt;, users can earn cashback without any extra effort.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>A Tiny Retry Utility That Saves You From Random Failures</title>
      <dc:creator>Enoch</dc:creator>
      <pubDate>Sun, 26 Apr 2026 02:37:17 +0000</pubDate>
      <link>https://dev.to/enochcreator/a-tiny-retry-utility-that-saves-you-from-random-failures-jai</link>
      <guid>https://dev.to/enochcreator/a-tiny-retry-utility-that-saves-you-from-random-failures-jai</guid>
      <description>&lt;p&gt;Sometimes the difference between a flaky system and a reliable one is just a few lines of retry logic. Network calls fail, APIs timeout, and transient issues happen more often than we’d like to admit.&lt;/p&gt;

&lt;p&gt;Instead of scattering retry logic everywhere, here’s a small reusable utility with exponential backoff:&lt;/p&gt;

&lt;p&gt;// Simple retry utility with exponential backoff&lt;br&gt;
public static  T retry(Supplier task, int maxAttempts) {&lt;br&gt;
    int attempt = 0;&lt;br&gt;
    long delay = 200;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;while (true) {
    try {
        return task.get();
    } catch (Exception e) {
        if (++attempt &amp;gt;= maxAttempts) {
            throw e;
        }
        try {
            Thread.sleep(delay);
        } catch (InterruptedException ignored) {}
        delay *= 2; // exponential backoff
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;}&lt;/p&gt;

&lt;p&gt;Why this works:&lt;/p&gt;

&lt;p&gt;Handles temporary failures (network hiccups, rate limits)&lt;/p&gt;

&lt;p&gt;Exponential backoff reduces pressure on downstream services&lt;/p&gt;

&lt;p&gt;Keeps your business logic clean and focused&lt;/p&gt;

&lt;p&gt;Usage example:&lt;/p&gt;

&lt;p&gt;String result = retry(() -&amp;gt; apiCall(), 3);&lt;/p&gt;

&lt;p&gt;Simple, effective, and saves you from a lot of random headaches in production.&lt;/p&gt;

</description>
      <category>backend</category>
      <category>java</category>
      <category>programming</category>
      <category>softwaredevelopment</category>
    </item>
  </channel>
</rss>
