This is an Auto Link Injector Script for SEO & Backlinks (a small JavaScript program that runs in your browser).
Its job: automatically insert an <a> (text link) into the footer (or any element you choose) on selected websites/domains.

Features:

  • Domain-specific – only runs on domains you set in the @match lines.
    Example:

				
					// @match        *://*.example.com/*
// @match        *://example.com/*

				
			

→ Will only run on example.com.

  • Automatic footer injection – by default, it inserts the link into the <footer> element.

  • Customizable link – you set the link text, URL, and whether it opens in a new tab:

				
					linkText: 'Visit Our Partner',
linkHref: 'https://your-target-domain.com',
linkTarget: '_blank',

				
			
  • Flexible placementinsertPosition can be:

    • "append" → add inside footer at the end (default)

    • "prepend" → at the beginning of footer

    • "before" → before the footer element

    • "after" → after the footer element

    • "replace" → replace the footer with just the link

  • Orange styling – automatically applies a CSS class (tm-orange-link) with orange color and hover effect.

  • Resilient – if the page reloads content dynamically (like in single-page apps), it re-adds the link if it disappears.

🛠️ How to Use It

Step 1: Install Tampermonkey

Step 2: Create New Script

  • Click on the Tampermonkey icon → Dashboard+ Create a new script.

  • Paste the full script you provided.

Step 3: Edit Settings

Inside the script, adjust this block:

				
					const settings = {
  insertSelector: 'footer',    // where to insert link
  insertPosition: 'append',    // append/prepend/replace/etc
  linkText: 'Visit Our Partner',
  linkHref: 'https://your-target-domain.com',
  linkTarget: '_blank',
  addCss: true,
  cssClass: 'tm-orange-link'
};

				
			
  • Change linkText → what the link shows.

  • Change linkHref → the site the link points to.

  • Change insertSelector if you want to place the link somewhere else (e.g., #colophon, .site-footer).

Step 4: Update @match

At the top of the script:

				
					// @match        *://*.example.com/*
// @match        *://example.com/*

				
			

Change example.com → to the domains where you want the script to run (e.g., ampipaint.com).

Step 5: Save & Enable

  • Press Ctrl+S (save) in Tampermonkey editor.

  • Make sure the script is enabled.

  • Visit the target site → you’ll see your link injected in the footer automatically.

				
					// ==UserScript==
// @name         Auto Link Injector
// @namespace    https://carodevsystem.com
// @version      1.0
// @description  Automatically insert an <a> link into footer or any selector for selected domains. Stylish orange link by default.
// @author       Carodev System
// @match        ://.example.com/*
// @grant        none
// @run-at       document-end
// ==/UserScript==

(function () {
  'use strict';

  /* ---------- SETTINGS: change these ---------- */
  const settings = {
    // The selector where you want to insert the link. If not found, it appends to document.body.
    insertSelector: 'footer',           // e.g. 'footer' or '.site-footer' or '#colophon'
    insertPosition: 'append',           // 'append' | 'prepend' | 'before' | 'after' | 'replace'
    linkText: 'Best Paint in Lahore',
    linkHref: 'https://your-target-domain.com',
    linkTarget: '_blank',               // '_self' or '_blank'
    addCss: true,                       // apply orange styling
    cssClass: 'tm-orange-link'          // custom class name
  };
  /* ------------------------------------------- */

  // Wait for an element to exist (with timeout). Promisified helper.
  function waitFor(selector, timeout = 8000) {
    return new Promise((resolve) => {
      const el = document.querySelector(selector);
      if (el) return resolve(el);
      const observer = new MutationObserver(() => {
        const found = document.querySelector(selector);
        if (found) {
          observer.disconnect();
          resolve(found);
        }
      });
      observer.observe(document.documentElement, { childList: true, subtree: true });
      setTimeout(() => {
        observer.disconnect();
        resolve(null);
      }, timeout);
    });
  }

  function createLink() {
    const a = document.createElement('a');
    a.textContent = settings.linkText;
    a.href = settings.linkHref;
    a.target = settings.linkTarget;
    a.rel = settings.linkTarget === '_blank' ? 'noopener noreferrer' : '';
    a.className = settings.cssClass;
    return a;
  }

  function inject(target, link, position = 'append') {
    if (!target) {
      if (position === 'replace') {
        // replace document body entirely? fallback to append body
        document.body.appendChild(link);
      } else {
        document.body.appendChild(link);
      }
      return;
    }
    switch (position) {
      case 'append':
        target.appendChild(link);
        break;
      case 'prepend':
        target.insertBefore(link, target.firstChild);
        break;
      case 'before':
        target.parentNode && target.parentNode.insertBefore(link, target);
        break;
      case 'after':
        target.parentNode && target.parentNode.insertBefore(link, target.nextSibling);
        break;
      case 'replace':
        target.parentNode && target.parentNode.replaceChild(link, target);
        break;
      default:
        target.appendChild(link);
    }
  }

  async function run() {
    // try to find selector first; if not found in 4s append to body
    const target = await waitFor(settings.insertSelector, 4000);
    const link = createLink();

    // stylistic default: orange link
    if (settings.addCss) {
      const styleId = 'tm-orange-link-style';
      if (!document.getElementById(styleId)) {
        const s = document.createElement('style');
        s.id = styleId;
        s.textContent = `
          .${settings.cssClass} {
            color: #ff7f11 !important;
            text-decoration: none !important;
            font-weight: 600;
            padding-left: 6px;
            padding-right: 6px;
          }
          .${settings.cssClass}:hover {
            text-decoration: underline !important;
            opacity: 0.95;
          }
        `;
        document.head && document.head.appendChild(s);
      }
    }

    inject(target, link, settings.insertPosition);

    // Keep link in footer for SPAs where content re-renders:
    // observe footer and re-add if removed
    if (target) {
      const obs = new MutationObserver((mutations) => {
        const exists = document.body.contains(link);
        if (!exists) {
          // try to re-insert
          const t = document.querySelector(settings.insertSelector) || document.body;
          inject(t, createLink(), settings.insertPosition);
        }
      });
      obs.observe(document.documentElement, { childList: true, subtree: true });
    }
  }

  // Run
  run();

})();
				
			
Scroll to Top