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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:40:34+00:00 2026-05-25T19:40:34+00:00

This is my userscript: // ==UserScript== // @name wykopSpamBlock // @namespace wykopSpamBlock // @description

  • 0

This is my userscript:

// ==UserScript==
// @name           wykopSpamBlock
// @namespace      wykopSpamBlock
// @description    Skrypt ukrywający sponsorowane i polecane wykopy w serwisie wykop.pl 3.0
// @include        http://www.*wykop.pl/
// @include        http://www.*wykop.pl/strona/*
// @include        http://www.*wykop.pl/wykopalisko*
// @include        http://www.*wykop.pl/hity* 
// ==/UserScript==

(function() {

  function block(element) {

    element.style.display = 'none';
    console.log('It works');

  }

  //////////////////////////////////////////////////////////////////////

  var Filter = new RegExp('^http://www.wykop.pl/link/partnerredirect/');
  var Entries = document.getElementById('body-con').getElementsByClassName('entry');
  var Links;

  //////////////////////////////////////////////////////////////////////

  for (i = 0; i < Entries.length; i++) {

    Links = Entries.item(i).getElementsByTagName('div').item(0).getElementsByClassName('content').item(0).getElementsByTagName('header').item(0).getElementsByTagName('p').item(0).getElementsByTagName('a');

    if (Filter.test(Links.item(1).href) || Filter.test(Links.item(2).href)) {
      block(Entries.item(i));
    }

  }

})();

It works fine in Chrome and Firefox (GreaseMonkey), but it doesn’t in Opera. I get this error:

User Javascript thread
Uncaught exception: TypeError: Cannot convert 'Entries.item(i).getElementsByTagName('div').item(0).getElementsByClassName('content').item(0)' to object
Error thrown at line 30, column 4 in <anonymous function>():
    Links = Entries.item(i).getElementsByTagName('div').item(0).getElementsByClassName('content').item(0).getElementsByTagName('header').item(0).getElementsByTagName('p').item(0).getElementsByTagName('a');
called from line 11, column 0 in program code:
    (function() {

And the question is, what’s wrong?

//edit

For people who can’t read that:

// ==UserScript==
// @name           wykopSpamBlock
// @namespace      wykopSpamBlock
// @description    Skrypt ukrywający sponsorowane i polecane wykopy w serwisie wykop.pl 3.0
// @include        http://www.*wykop.pl/
// @include        http://www.*wykop.pl/strona/*
// @include        http://www.*wykop.pl/wykopalisko*
// @include        http://www.*wykop.pl/hity* 
// ==/UserScript==

(function() {

  function block(element) {

    element.style.display = 'none';
    console.log('It works');

  }

  //////////////////////////////////////////////////////////////////////

  var Filter = new RegExp('^http://www.wykop.pl/link/partnerredirect/');
  var Entries = document.getElementById('body-con').getElementsByClassName('entry');

  //////////////////////////////////////////////////////////////////////

  for (i = 0; i < Entries.length; i++) {

    var EntriesItem = Entries.item(i);
    var Div = EntriesItem.getElementsByTagName('div');
    var DivItem = Div.item(0);
    var Content = DivItem.getElementsByClassName('content');
    var ContentItem = Content.item(0);
    var Header = ContentItem.getElementsByTagName('header');
    var HeaderItem = Header.item(0);
    var Paragraph = HeaderItem.getElementsByTagName('p');
    var ParagraphItem = Paragraph.item(0);
    var Links = ParagraphItem.getElementsByTagName('a');

    if (Filter.test(Links.item(1).href) || Filter.test(Links.item(2).href)) {
      block(Entries.item(i));
    }

  }

})();

and error:

[26.09.2011 20:35:07] JavaScript - http://www.wykop.pl/
User Javascript thread
Uncaught exception: TypeError: Cannot convert 'ContentItem' to object
Error thrown at line 35, column 4 in <anonymous function>():
    var Header = ContentItem.getElementsByTagName('header');
called from line 11, column 0 in program code:
    (function() {

//edit 2

Here is full html of entry. Content starts in 21 line.

<article class="entry brbotte8 pding15_0  {id:891309}">
  <div class="clr rel">

    <div class="fleft diggbox">
      <a href="http://www.wykop.pl/link/dig/%7E2/891309/55a55552de3fac6ececb6a8933938e71-1317062985/log_ref_0,index,log_ref_m_0,index,log_ref_n_0," class="block tcenter tdnone diggit ">
        <span class="icon inlblk diggcount cff5917 large fbold vtop animated ">
          22
        </span>
        <span class="block action small br3 bre3">
          wykop
        </span>
      </a>
    </div>

    <a href="http://www.wykop.pl/ramka/891309/policjant-strzelil-nastolatkowi-w-twarz-taserem-wideo/" class="image  rel fright">
      <div class="lazy">
        <!--<img src="http://c0692282.3.cdn.imgwykop.pl/hi_34VehOZEwdnDXdwlMEBOWbkmNGIzrPM0.jpg" alt="Policjant strzelił nastolatkowi w twarz taserem [wideo" class="fright border marginleft15" width="104" height="74" />-->
      </div>
    </a>

    <div class="content">

      <header>
        <h2 class="xx-large lheight20">
          <a href="http://www.wykop.pl/ramka/891309/policjant-strzelil-nastolatkowi-w-twarz-taserem-wideo/"  class="link">
            <span class="fbold">Policjant strzelił nastolatkowi w twarz taserem [wideo</span>
          </a>
        </h2>
        <p class="small cc6">
          <a href="http://www.wykop.pl/reklama/" class="link gray" title="Przejdź do Reklama Wykop.pl">
            <span>
              Wykop Poleca
            </span>
          </a> 
          dodany 
          <time title="2011-09-26 19:37:24" datetime="2011-09-26T19:37:24+02:00" pubdate>
            1 godz. temu
          </time> 
          przez 
          <a href="http://www.wykop.pl/ludzie/Saper86/" class="link gray color color-1">
            <span>
              Saper86
            </span>
          </a>
           z 
          <a href="http://www.wykop.pl/link/partnerredirect/891309/policjant-strzelil-nastolatkowi-w-twarz-taserem-wideo/" rel="nofollow" class="link gray" title="Przejdź do Policjant strzelił nastolatkowi w twarz taserem [wideo">
            <span>
              gadzetomania.pl
            </span>
          </a>                                      
          do 
          <a href="http://ciekawostki.wykop.pl/" title="Ciekawostki" class="link gray" rel="nofollow">
            <span>
              Ciekawostki
            </span>
          </a>
          <a href="http://www.wykop.pl/link/891309/policjant-strzelil-nastolatkowi-w-twarz-taserem-wideo/" class="marginleft10 caf small tdnone">
            <span class="icon inlblk comments mini vtop margintop5 ">&nbsp;</span> 
            <span class="hvline  link gray">13 komentarzy</span>
          </a>
        </p>
      </header>

      <p class="lheight18">
        <a href="http://www.wykop.pl/link/891309/policjant-strzelil-nastolatkowi-w-twarz-taserem-wideo/" class="block ce1">
          <span class="c22">Oceńcie sami czy postąpił właściwie</span>
        </a>
      </p>

    </div>

  </div>

</article>
  • 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-25T19:40:35+00:00Added an answer on May 25, 2026 at 7:40 pm

    I’d suggest breaking each piece of this long line into individual steps and find out which of the 8 steps is failing and that should give you a clue:

    Links = Entries.item(i).getElementsByTagName('div').item(0).getElementsByClassName('content').item(0).getElementsByTagName('header').item(0).getElementsByTagName('p').item(0).getElementsByTagName('a');
    

    I really have no idea what’s causing the problem. It works for both of us in jsFiddle, just not in the greasemonkey environment. Do you have any other greasemonkey scripts that are modifying the page and changing the DOM on you?

    Other than that, the only other thing I can think of is to switch to using document.querySelectorAll() when it’s present. Since that is supported in recent versions of Opera, that may avoid whatever issues your code is having. You can see a sample implementation in this jsFiddle: http://jsfiddle.net/jfriend00/5hJLn/. This selector doesn’t generate exactly the same result as your code with any HTML, but I think it works for the HTML you have. You can consider tweaking the selector if you want. This selector is a little less brittle because it doesn’t rely on the exact position of various tags as much as your code.

    The general idea (implemented in that jsFiddle) is like this:

    if (document.querySelectorAll) {
        var Links = document.querySelectorAll("#body-con .content header p a");
        // turn the links we found green just to show that the code executed properly
        for (var j = 0; j < Links.length; j++) {
            Links[j].className = "target2";
        }
    } else {
    
        var Entries = document.getElementById('body-con').getElementsByClassName('entry');
    
    
        for (var i = 0; i < Entries.length; i++) {
    
            var EntriesItem = Entries.item(i);
            var Div = EntriesItem.getElementsByTagName('div');
            var DivItem = Div.item(0);
            var Content = DivItem.getElementsByClassName('content');
            var ContentItem = Content.item(0);
            var Header = ContentItem.getElementsByTagName('header');
            var HeaderItem = Header.item(0);
            var Paragraph = HeaderItem.getElementsByTagName('p');
            var ParagraphItem = Paragraph.item(0);
            var Links = ParagraphItem.getElementsByTagName('a');
    
            // turn the links we found red just to show that the code executed properly
            for (var j = 0; j < Links.length; j++) {
                Links[j].className = "target";
            }
    
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code // // ==UserScript== // @name test // @description test //
Here is my script code: // ==UserScript== // @name test // @description test //
So I'm working on a Greasemonkey UserScript for Clients From Hell http://clientsfromhell.net/ and I'm
I have this in my UserScript file: window.testMyFunctionBLah = function() { alert('hey'); } window.setTimeout(
I have a greasemonkey user script with this single line of code... window.close(); but
This is a bit of a long shot, but if anyone can figure it
This is starting to vex me. I recently decided to clear out my FTP,
This is kinda oddball, but I was poking around with the GNU assembler today
This might seem like a stupid question I admit. But I'm in a small
This is a difficult and open-ended question I know, but I thought I'd throw

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.