0

So I got this code:

// ==UserScript==

// @name        plugin
// @namespace   http://localhost/
// @description Makes good
// @include     http://www.randomsite.com/*
// @version     1

// @grant       GM_addStyle

// ==/UserScript==



GM_addStyle ( "\
.content-box {\
    background-color: #ffffff;\
    width: 100px;\
    height: 50px;\
    position: fixed;\
    overflow: hidden;\
    z-index: 5;\
    top: 50;\
}\

" );


function createDiv(){
var div = document.body.createElement("DIV");
div.className = "content-box";
div.innerHTML = "Content";

}


var post = document.getElementsByCLassName("entry iC");


for(var i=0; i<entry.length; i++){
createDiv();
entry[i].appendChild(div);
}

And HTML DOM:

<html>
<head>

<body class="night ">
<script type="text/javascript" src="http://static.criteo.net/js/px.js?ch=1">
<script type="text/javascript" src="http://static.criteo.net/js/px.js?ch=2">

<div id="nav" class="clearfix m-reset-position">
<div id="site" class="m-reset-padding m-reset-margin">
<div class="wrapper clearfix m-reset-padding">
<div class="grid-full"> </div>
<div class="grid m-reset-float">
<div class="grid-main grid-main m-reset-margin">
<div class="nav bspace rbl-block">
<div id="commentFormContainer" class="rbl-block wblock mark-bg dC">
<ul id="itemsStream" class="comments-stream">
<li class="entry iC ">
<div class="wblock lcontrast dC " data-id="20085297" data-type="entry">
<ul class="sub">
</li>

I want to acces entry iC and append it a div child. Any ideas why this is not working?

Ps: script is acessing the site because css is added in the head section.

Thanks in advance for help.

Zaithz
  • 1
  • 1
    Have you [checked your console](http://stackoverflow.com/documentation/javascript/185/hello-world/714/using-console-log) for errors? – Mike Cluck Oct 14 '16 at 20:11
  • Yeah, i got some but i think any of these refer to my script `ReferenceError: bmone2n is not defined ReferenceError: bmone2n is not defined ReferenceError: bmone2n is not defined ReferenceError: bmone2n is not defined ReferenceError: buildAdSlot is not defined TypeError: _.q is not a function TypeError: _.q is not a function ReferenceError: buildTextAd is not defined ReferenceError: adSlot is not defined TypeError: _.q is not a function ReferenceError: wfocusinit is not defined` – Zaithz Oct 14 '16 at 20:20
  • Since you are using `position: fixed`, there is no point in trying to add to the `entry iC` node. Just use the linked technique. – Brock Adams Oct 14 '16 at 22:08
  • 1
    @BrockAdams Thanks for the link. It's working :) – Zaithz Oct 15 '16 at 10:45

0 Answers0