* WalrusIRC

You need to have 5 posts and not be part of restricted usergroups in order to use the WalrusIRC embedded shoutbox. However, you can also access our IRC channel called #CodeWalrus via EFnet.

Author Topic: Troubleshooting a (probably stupid) javascript error  (Read 687 times)

0 Members and 1 Guest are viewing this topic.

Offline WholeWheatBagels

  • Full User
  • Join Date: May 2016
  • Location: "yes"
  • Posts: 140
  • Post Rating Ratio: +2/-0
  • call me Bagels
    • detjensrobert
    • @@detjensrobert
    • WholeWheatBagels
  • Gender: Male
Troubleshooting a (probably stupid) javascript error
« on: November 12, 2016, 01:17:31 am »
So I've been messing around with Javascript lately.
I wrote this to mess with some page code:
Code: [Select]
javascript:
var divs = document.getElementsByClassName("corrupted-repair-button");
for (var x = 0; x < divs.length; x++) {
    var elem=divs[x];
    elem.removeAttribute('hidden')
}
What I'm trying to do is remove a "hidden" attribute from an element with that class name.
Thing is, it works in the Inspect console,but when I stick it in a bookmark or the onmibar it never works and I have no idea why.

Pretty new to JS so it's probably staring me straight in the face and I haven't caught it yet.
« Last Edit: November 12, 2016, 01:30:49 am by WholeWheatBagels »


Living in another world to you.



Also in case you were wondering Frankie did go to Hollywood

Offline Snektron

  • Lvl 69 Russian Snake
  • Super User
  • Join Date: Dec 2014
  • Location: Netherlands
  • Posts: 3165
  • Post Rating Ratio: +32/-0
  • SSSssssss.....
    • RobinDeWalvis
    • Kzyrox
    • RobinDeWalvis
    • quantuminfinity
  • Gender: Male
Re: Troubleshooting a (probably stupid) javascript error
« Reply #1 on: November 12, 2016, 09:39:21 am »
But does it work when you paste it in the addres bar? Watcvh out though, Chrome removes the javascript: part when you paste it sop you have to type it manually. Im not sure it it does that with bookmarks too.
  • Calculators owned: TI-84+
Legends say if you spam more than DJ Omnimaga, you will become a walrus...


Offline ben_g

  • Full User
  • Safe-haven access
  • Join Date: Dec 2014
  • Location:
  • Posts: 167
  • Post Rating Ratio: +12/-0
Re: Troubleshooting a (probably stupid) javascript error
« Reply #2 on: November 12, 2016, 12:03:27 pm »
I don't think bookmarks are supposed to contain multiple lines. Have you tried writing it all on one line like this?
Code: [Select]
javascript:var divs=document.getElementsByClassName("corrupted-repair-button");for (var x=0;x<divs.length;x++) {divs[x].removeAttribute('hidden');}

Offline WholeWheatBagels

  • Full User
  • Join Date: May 2016
  • Location: "yes"
  • Posts: 140
  • Post Rating Ratio: +2/-0
  • call me Bagels
    • detjensrobert
    • @@detjensrobert
    • WholeWheatBagels
  • Gender: Male
Re: Troubleshooting a (probably stupid) javascript error
« Reply #3 on: November 13, 2016, 01:05:21 am »
I have tried all of the above to no luck. Bookmarks automatically put everything on the same line, so no problems there; I know they work b/c the image replacer script (BATMAN) works as a bookmark.

Maybe it has something to do with the console needing to be in this mode and not the default "top" mode?

Living in another world to you.



Also in case you were wondering Frankie did go to Hollywood

Offline p2

  • CodeWalrus Staff
  • Super User
  • Moderator
  • CodeWalrus Supporter
  • *
  • Join Date: Aug 2016
  • Location: Germany
  • Posts: 2300
  • Post Rating Ratio: +9/-0
  • *Wubba lubba dub dub*
    • KaliPhobos
  • Gender: Male
Re: Troubleshooting a (probably stupid) javascript error
« Reply #4 on: November 15, 2016, 11:55:03 am »
in your first post... I think you forgot the ; after the elem.removeAttribute('hidden')
*Will try something out, now ^^

ok this code worked for me:

Code: [Select]
var divs = document.getElementsByClassName("corrupted-repair-button");
for (var x = 0; x < divs.length; x++) {
  divs[x].style.hidden='';
}


If you have jQuery you can do it a lot eaier by just calling
Code: [Select]
$('.corrupted-repair-button').style.hidden='';At least I think so... ^^
« Last Edit: November 15, 2016, 12:05:32 pm by p2 »
  • Calculators owned: ti-83+, ti-84+, ti-84+, ti-84+se, ti-84+se(te), ti-nsphire, ti-nsphire CX-CAS, ti-voyage, ti-voyage, Who reads this list anyways...?
Anyway war sucks. Just bring us your food instead of missiles  :P ~ DJ Omnimaga (11.10.2016 20:21:48)
if you cant get a jframe set up, draw stuff to it, and receive input, i can only imagine how horrible your game code is _._   ~ c4ooo (14.11.2016 22:44:07)
If they pull a Harambe on me tell my family I love them ~ u/Pwntear37d (AssangeWatch /r/)
make Walrii great again ~ DJ Omnimaga (28.11.2016 23:01:31)
God invented the pc, satan the smartphone I guess ~ p4nix (16.02.2017 22:51:49)

 


You can also use the following HTML or bulletin board code to share it on your page or forum signature!


Also do not forget to check our affiliates below.
Planet Casio TI-Planet Calc.news BroniesQC BosaikNet Velocity Games