My simple innerHTML.replace is breaking other scripts

98 views
Skip to first unread message

Patrick Mariani

unread,
Sep 11, 2013, 7:55:32 PM9/11/13
to chromium-...@chromium.org
Hey all - 

some of the chrome users of http://www.mtbnj.com/forum/index.php (vbulletin) requested an extension which 
eliminated the black dot in the upper right hand corner of the top banner  - fairly simple replace - but it is breaking all
of the other scripts on the page (drop down menus, message editor controls..) - the board admin is not interested in 
fixing this, and empty tables are not rendered in ie or firefox


am i missing an important OO web concept here?  (old unix/c grump here ;)

many thanks
pat


manifest

{
  "manifest_version": 2,


  "name": "no dots",

  "description": "Remove annoying dots from mtbnj.com",

  "version": "1.0",
  
"content_scripts": [
{

"all_frames": true,
"run_at": "document_idle",
"js": ["modBorder.js"]
    }
]
}

here is my content_script

var str1 = /border-style: solid;/,
str2 = 'border-style: none;';
 if (document.body.nodeName === 'BODY') {
    document.body.innerHTML =   document.body.innerHTML.replace(str1, str2);
}

Adam Barth

unread,
Sep 11, 2013, 8:00:01 PM9/11/13
to Patrick Mariani, Chromium-extensions
I wonder if you might have more luck injecting some CSS into the page rather than calling replace() on the innerHTML.  The way your script works currently, it's causing the entire page to be re-parsed, which is probably what's breaking things.

Adam



--
You received this message because you are subscribed to the Google Groups "Chromium-extensions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extens...@chromium.org.
To post to this group, send email to chromium-...@chromium.org.
Visit this group at http://groups.google.com/a/chromium.org/group/chromium-extensions/.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/8536a3df-13e8-4818-85f9-36273a575d29%40chromium.org.
For more options, visit https://groups.google.com/a/chromium.org/groups/opt_out.

Patrick Mariani

unread,
Sep 11, 2013, 9:06:49 PM9/11/13
to chromium-...@chromium.org, Patrick Mariani
Thanks Adam, 
it appears the style is only related to this element - (I think that is the correct terminology)
i can probably navigate to that element and use the element.style method to change it - not sure how to get there - going to be ugly with no id=
(suggestions appreciated.)  
p.

element code below - need to change 'solid' to 'none'

<td valign="center" align="center" style="vertical-align: top; padding: 0px;
border-width: 1px; 
border-style: solid; border-color: #000000 "></td>
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extensions+unsub...@chromium.org.

Patrick Mariani

unread,
Sep 12, 2013, 7:45:27 AM9/12/13
to chromium-...@chromium.org, Patrick Mariani
Got it, was able to get to a point to use the style.borderStyle property....
Thanks for pointing in the right direction.
p

Adrian Aichner

unread,
Sep 12, 2013, 8:01:23 AM9/12/13
to Patrick Mariani, Chromium-extensions
On Thu, Sep 12, 2013 at 1:45 PM, Patrick Mariani <pats...@gmail.com> wrote:
Got it, was able to get to a point to use the style.borderStyle property....
Thanks for pointing in the right direction.
p

Patrick, what did you end up using?

Your findings could be helpful to others.

Reply all
Reply to author
Forward
0 new messages