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 6039145
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T06:19:33+00:00 2026-05-23T06:19:33+00:00

JScript does my head in most days, but poorly designed sites do it even

  • 0

JScript does my head in most days, but poorly designed sites do it even more. Foursquare’s is one such example in respect of its superusers.

Desired Outcome

A greasemonkey script that will look through each occurrence of the DIV class searchResult, and after the DIV class name append two new A HREF elements similar to these:

<a href="/venue/venueid/edit">Manage venue</a> <a href="/edit_venue?vid=venueid">Edit venue</a>

Scenairo

I would like to make the life of their superusers a little easier using Greasemonkey. The intent is to modify a specific page on the site (https://foursquare.com/search), and add a number of extra links to jump directly to specific pages for a venue that would make the workflow faster.

I’ve looked around for examples of how to do this (learn through reverse engineering), but I get stuck on if I should be using RegEx or something else.

Example

On the search results page (https://foursquare.com/search?q=dump&near=Perth%2C+Australia), there is a list of venues returned. The code for each venue returned on the search results looks exactly like this:

<div class="searchResult">
            <div class="icon"><img src="https://4sqstatic.s3.amazonaws.com/img/categories/parks_outdoors/default-29db364ef4ee480073b12481a294b128.png" class="thumb" /></div>
            <div class="info">
              <div class="name"><a href="/venue/4884313">Staff Smoking Spot / Dumpster Dock</a></div>
              <div class="address"><span class="adr"></span></div>

              <div class="specialoffer"></div>

            </div>

            <div class="extra">
              <div class="extra-tip"><div><a href="/venue/4884313">0 tips</a></div></div>
              <div class="extra-checkins"><div>10 check-ins</div></div>
            </div>
          </div>

Work so far

Looking around for answers, this is what I have come up with (below). Needless to say, it isn’t detecting where it needs to insert the A HREF elements at all, and doesn’t loop through all of the searchResult elements output on the page, let alone construct the link correctly.

// First version
var elmNewContent = document.createElement('a');
elmNewContent.href = sCurrentHost;
elmNewContent.target = "_blank";
elmNewContent.appendChild(document.createTextNode('edit venue'));
var elmName = document.getElementById('name');
elmName.parentNode.insertBefore(elmNewContent, elmName.nextSibling);
  • 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-05-23T06:19:34+00:00Added an answer on May 23, 2026 at 6:19 am

    This is pretty simple using jQuery.
    Here’s the whole script, since it was a 5-minute job…

    // ==UserScript==
    // @name     _Square away foursquare
    // @include  http://foursquare.com/*
    // @include  https://foursquare.com/*
    // @require  http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js
    // @grant    GM_addStyle
    // ==/UserScript==
    
    var SearchRezLinks  = $("div.searchResult div.name > a");
    
    /*--- Link is like: <a href="/venue/6868983">Dumpling King</a>
        where 6868983 is venue ID.
    
        Want to add: <a href="/venue/venueid/edit">Manage venue</a>
        <a href="/edit_venue?vid=venueid">Edit venue</a>
    */
    SearchRezLinks.each ( function () {
    
        var jThis       = $(this);
        var venueID     = jThis.attr ('href').replace (/\D+(\d+)$/, '$1');
        jThis.parent ().append ('<a href="/venue/' + venueID + '/edit">Manage venue</a>');
        jThis.parent ().append ('<a href="/edit_venue?vid=' + venueID + '">Edit venue</a>');
    } );
    
    GM_addStyle ( "                                 \
        div.searchResult div.name > a + a {         \
            font-size:      0.7em;                  \
            margin-left:    2em;                    \
        }                                           \
    " );                                            
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Why does Microsoft.JScript work in the Code behind but not within a <% %>
I have some JScript which does some stuff with an ODBC connection. An exception
So when JScript is different from JavaScript, how does IE interpret jQuery, and all
I've got a JScript error on my page. I know where the error's happening,
Is it possible to use both JScript and VBScript in the same HTA? Can
I have a sparse array in Jscript, with non-null elements occuring at both negative
I am having problems with my JScript code. I am trying to loop through
I have to maintain a server-side script written in JScript (NOT Javascript) that needs
We have developed a large number of websites using ASP (jscript flavour), talking to
Has anyone had any experience targetting WSH in the way that VBScript , JScript

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.