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

  • Home
  • SEARCH
  • 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 6216993
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T07:20:50+00:00 2026-05-24T07:20:50+00:00

I am looking for a way to write a Greasemonkey script which will take

  • 0

I am looking for a way to write a Greasemonkey script which will take the following snippet of code and only show the code blocks consisting of <div class="A" where both “passtest” and “State1” are present.

<div class="A">
    <div class="B">
        <a href="/link1">
        <img class="imgClass" src="http://link.com/img.img" title="imgTitle"/>
        </a>
    </div>
    <div class="C">
        <span class="sc1">passtest</span>
        <br/>
        <em class="ec1">City1, State1</em>
    </div>
</div>
<div class="A">
    <div class="B">
        <a href="/link1">
        <img class="imgClass" src="http://link.com/img.img" title="imgTitle"/>
        </a>
    </div>
    <div class="C">
        <span class="sc1">failtest </span>
        <br/>
        <em class="ec1">City1, State1 </em>
    </div>
</div>
<div class="A">
    <div class="B">
        <a href="/link1">
        <img class="imgClass" src="http://link.com/img.img" title="imgTitle"/>
        </a>
    </div>
    <div class="C">
        <span class="sc1">passtest </span>
        <br/>
        <em class="ec1">City2, State2 </em>
    </div>
</div>

I found this from Dive Into Greasemonkey:

var allDivs, thisDiv;
allDivs = document.evaluate("//div[@class='sponsoredlink']", document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
for (var i = 0; i < allDivs.snapshotLength; i++) {
    thisDiv = allDivs.snapshotItem(i); 
    // do something with thisDiv 
}

I am looking at this code as the starting point for what I want to do. But, I am just a user, not a coder.

I understand the logic I need is:
For each div where class=”a” which does contain the text “passtest” and also does not contain “state1” do not display that div.

  • 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-24T07:20:51+00:00Added an answer on May 24, 2026 at 7:20 am

    Here’s a script that does that, using jQuery. The hard part is choosing the selectors.

    // ==UserScript==
    // @name     Show State1 passes only.
    // @include  http://YOUR_SITE/YOUR_PATH/*
    // @require  http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js
    // ==/UserScript==
    
    $("div.A")  .hide ()
                .has ("span.sc1:contains('passtest')")
                .has ("em.ec1:contains('State1')")
                .show ();
    

    Note that :contains() is case-sensitive.

    See the code in action at jsFiddle.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am looking for a way to write a script that will take around
I am looking for the simplest way to write the following Java code Arrays.asList(1L);
Is there a far shorter way to write the following code? my_string = my_string.replace('A',
I'm looking for a way to write code such that when a program is
I'm looking for a way to write code that tests whether a value is
I'm looking for a simpler way to write this tiny bit of code: if
I'm looking for way to write Javascript programs / scripts on desktop, not inside
I am looking to see a simple way to read from and write to
I'm looking for way to PHP to detect if a script was run from
I looking for a way, specifically in PHP that I will be guaranteed 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.