Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8648079
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T13:13:54+00:00 2026-06-12T13:13:54+00:00

I am trying to write a user script for Chrome which simply adds an

  • 0

I am trying to write a user script for Chrome which simply adds an Element to a website, but with my limited Javascript knowledge I’m really not very successful to do this.

Example of subject:

<html>
<body>
<p class="listcaption">......................................</p>
<p class="listrow" id="listrow_aka_battlep"><span class="small"><b><a href="item.php?action=academy"></a>-: </b> / <b> : </b>0000</span></p>
<p class="listrow" id="listrow_char_mission"><a href="ability.php">text</a> | <a href="item.php?action=missiondesc"> text</a></p>
<p class="listrow" id="listrow_clan"><b>some</b><a href="clanmenu.php?action=manageclan">-------</a> &nbsp;|&nbsp; <a href="fight.php?action=groupjoinrand" target="mainFrame" title="group"></a></p>
<p class="listrow" id="listrow_group"><b>group: </b><a href="clanmenu.php?action=groupmenu">~~~~~</a></p>
<p class="listrow" id="listrow_lifep"><b>LP: </b>(<span class="healthok"><b>000</b></span>/000)</p>
<p class="listrow" id="listrow_money"><b>gold: </b>629 &nbsp;&nbsp;&nbsp;&nbsp;(<a href="item.php?action=moneydrop1"></a> | <a href="item.php?action=moneytransfer1"></a>)</p>
<p class="listrow" id="listrow_int"><b>......</b>0000<span class="healthok" id="speedok">000</span>000</p>
<p class="listrow" id="listrow_attackp"><b>text</b>000<span class="valueincreased">000</span>text</p>
<p class="listrow" id="listrow_attackw" title=""><b>............</b>text</p>
<p class="listrow" id="listrow_defensep"><b>?????????????</b>0000<span class="valueincreased">000000</span></p>
<p class="listrow" id="listrow_defensew" title="100%"><b>000000000000</b>texts</p>
<p class="listrow" id="listrow_neck"><b>neck:</b>something</p>
<p class="listrow" id="listrow_special"><a href="item.php?action=special">Special</a></p><p class="listrow" id="listrow_status"><span class="small"></span></p>
</body></html>

Desired Output :

<html>
<body>
<p class="listcaption">......................................</p>
<p class="listrow" id="listrow_aka_battlep"><span class="small"><b><a href="item.php?action=academy"></a>-: </b> / <b> : </b>0000</span></p>
<p class="listrow" id="listrow_char_mission"><a href="ability.php">text</a> | <a href="item.php?action=missiondesc"> text</a></p>
<p class="listrow" id="listrow_clan"><b>some</b><a href="clanmenu.php?action=manageclan">-------</a> &nbsp;|&nbsp; <a href="fight.php?action=groupjoinrand" target="mainFrame" title="group"></a></p>
<p class="listrow" id="listrow_group"><b>group: </b><a href="clanmenu.php?action=groupmenu">~~~~~</a></p>
<p class="listrow" id="listrow_lifep"><b>LP: </b>(<span class="healthok"><b>000</b></span>/000)</p>
<p class="listrow" id="listrow_money"><b>gold: </b>629 &nbsp;&nbsp;&nbsp;&nbsp;(<a href="item.php?action=moneydrop1"></a> | <a href="item.php?action=moneytransfer1"></a>)</p>
<p class="listrow" id="listrow_int"><b>......</b>0000<span class="healthok" id="speedok">000</span>000</p>
<p class="listrow" id="listrow_attackp"><b>text</b>000<span class="valueincreased">000</span>text</p>
<p class="listrow" id="listrow_attackw" title=""><b>............</b>text</p>
<p class="listrow" id="listrow_defensep"><b>?????????????</b>0000<span class="valueincreased">000000</span></p>
<p class="listrow" id="listrow_defensew" title="100%"><b>000000000000</b>texts</p>
<p class="listrow" id="listrow_neck"><b>neck:</b>something</p>
<p class="listrow" id="listrow_newlist"><a href="item.php?action=activate&amp;act_item_id=000029"><img src="../images/items/image1.gif" width="20" height="20" title="1" border="0" align="absmiddle"></a> |&nbsp; <a href="item.php?action=watch&amp;act_item_id=000016"><img src="../images/items/image2" width="20" height="20" title="2" border="0" align="absmiddle"></a>&nbsp;|&nbsp; <a href="item.php?action=watch&amp;act_item_id=0000061"><img src="../images/items/image3" width="20" height="20" title="3" border="0" align="absmiddle"></a>&nbsp;|&nbsp; <a href="item.php?action=watch&amp;act_item_id=000095"><img src="../images/items/image4.gif" width="20" height="20" title="4" border="0" align="absmiddle"></a></p>
<p class="listrow" id="listrow_special"><a href="item.php?action=special">Special</a></p><p class="listrow" id="listrow_status"><span class="small"></span></p>
</body></html>

I just want that the user script adds this list:

<p class="listrow" id="listrow_newlist"><a href="item.php?action=activate&amp;act_item_id=000029"><img src="../images/items/image1.gif" width="20" height="20" title="1" border="0" align="absmiddle"></a> |&nbsp; <a href="item.php?action=watch&amp;act_item_id=000016"><img src="../images/items/image2" width="20" height="20" title="2" border="0" align="absmiddle"></a>&nbsp;|&nbsp; <a href="item.php?action=watch&amp;act_item_id=0000061"><img src="../images/items/image3" width="20" height="20" title="3" border="0" align="absmiddle"></a>&nbsp;|&nbsp; <a href="item.php?action=watch&amp;act_item_id=000095"><img src="../images/items/image4.gif" width="20" height="20" title="4" border="0" align="absmiddle"></a></p>

Thank you all for helping me!

Update:

I’ve try to start with add this element:

<a href="item.php?action=activate&amp;act_item_id=000029"><img src="../images/items/image1.gif" width="20" height="20" title="1" border="0" align="absmiddle"></a>

It’s probably the wrong way to do this. (because it does work):

// ==UserScript==
// @name           my script
// @description    ...
// @author         ...
// @version        1.0
// ==/UserScript==
var links = document.getElementsByClassName( 'listrow' );
    ( var i = 0; i < links.length; i++ ) {
    var link = links[i];
    var newlist = document.createElement( 'a' );
    newlist.href = item.php?action=activate&amp;act_item_id=000029
    var the_image = document.createElement('img');
    the_image.src = '../images/image1.gif';
    newlink.appendChild(the_image);
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T13:13:55+00:00Added an answer on June 12, 2026 at 1:13 pm

    Grow to love jQuery, especially the Manipulation Functions.

    Here’s a complete Firefox/Greasemonkey and Chrome userscript that adds that paragraph. See the inline comments.

    // ==UserScript==
    // @name     _Add New paragraph at targeted location
    // @include  http://YOUR_SERVER.COM/YOUR_PATH/*
    // @grant    GM_addStyle
    // ==/UserScript==
    
    function GM_main ($) {
        var insertTarget    = $("#listrow_special");
    
        //-- Insert empty container paragraph before the target paragraph.
        insertTarget.before ('<p class="listrow" id="listrow_newlist"></p>');
    
        //-- Set this array to the unique parts of the links.
        var linkDatArray    = [
            ["activate&amp;act_item_id=000029", "image1.gif", "title 1"],
            ["watch&amp;act_item_id=000016",    "image2.gif", "title 2"],
            ["watch&amp;act_item_id=0000061",   "image3.gif", "title 3"],
            ["watch&amp;act_item_id=000095",    "image4.gif", "title 4"]
        ];
    
        //-- Now use the array to insert the links into the container paragraph.
        var contParag       = $("#listrow_newlist");
    
        $.each (linkDatArray, function (rowIdx, arryRow) {
            //-- Create empty link with correct action.
            var newLink     = $('<a href="item.php?action=' + arryRow[0] + '"></a>');
    
            //-- Insert the image into it.
            newLink.append (
                '<img src="../images/items/' + arryRow[1] + '" title="' + arryRow[2] + '">'
            );
    
            //-- Insert the link into the container paragraph.
            contParag.append (newLink);
    
            //-- Except for the last link, add our seperator characters.
            if (rowIdx  <  linkDatArray.length - 1) {
                contParag.append ('&nbsp;|&nbsp;');
            }
        } );
    }
    
    /*--- STYLE THE IMAGES (And anything else) WITH CSS!  NOT ATTRIBUTES.
    */
    //-- GM_addStyle() works on both Firefox and Chrome
    GM_addStyle ( '                     \
        #listrow_newlist a img {        \
            width:          20px;       \
            height:         20px;       \
            border:         none;       \
            vertical-align: middle;     \
        }                               \
    ' );
    
    //-- Fire the main/payload code
    add_jQuery (GM_main);
    
    //-- This is just a standard utility function
    function add_jQuery (callbackFn, jqVersion) {
        jqVersion       = jqVersion || "1.7.2";
        var D           = document;
        var targ        = D.getElementsByTagName ('head')[0] || D.body || D.documentElement;
        var scriptNode  = D.createElement ('script');
        scriptNode.src  = 'http://ajax.googleapis.com/ajax/libs/jquery/'
                        + jqVersion
                        + '/jquery.min.js'
                        ;
        scriptNode.addEventListener ("load", function () {
            var scriptNode          = D.createElement ("script");
            scriptNode.textContent  =
                'var gm_jQuery  = jQuery.noConflict (true);\n'
                + '(' + callbackFn.toString () + ')(gm_jQuery);'
            ;
            targ.appendChild (scriptNode);
        }, false);
        targ.appendChild (scriptNode);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been trying to write my first user script for Google Chrome. It
I have been trying to write my first user script for Google Chrome. It
I'm struggling with the syntax for this user script I'm trying to write, which
I am trying write a script where when a user clicks on a link,
I'm trying to write a script that will create a user in MediaWiki, so
I'm trying to write a bash script that wraps whatever the user wants to
I'm trying to write a custom powershell script that will create a local user
I'm trying to write a piece of code which use the user choice in
i'm trying to write a script that will get a user's geolocation - if
I am trying to write a script that I can give to user to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.