Greasy Fork is available in English.

Discuții » Cerere de creare

Remove under ul

§
Postat în: 19-01-2015
Editat în: 19-01-2015

Remove under ul

Hello there, I'm trying to make script that could remove this line li class="actionListItem minion minion-0 first" when its found

  • XXX
  • XXX
  • XXX

Help would be appreciated... tried lots of scripts by searching but nothing worked seems the HTML build in that website is different

wOxxOmMod
§
Postat în: 20-01-2015
Editat în: 20-01-2015

Edit: v2.

// ==UserScript==
// @name          fallensword.com - delete minions action
// @include       http://www.fallensword.com/*cmd=world*
// @grant         none
// ==/UserScript==

window.addEventListener('DOMContentLoaded', function(e) {

  var container = document.querySelector('ul#actionList');
  if (!container) {
    console.log('Action container not found on the page');
    return;
  }

  new MutationObserver(function(mutations){
    for (var i=0, ml=mutations.length, m; (i<ml) && (m=mutations[i]); i++)
      for (var j=0, nodes=m.addedNodes, nl=nodes.length, n; (j<nl) && (n=nodes[j]); j++)
        if (n.className == 'actionListItem minion minion-0 first')
          n.parentNode.removeChild(n);
  })
  .observe(container, {subtree:true, childList:true});
});
§
Postat în: 20-01-2015

sadly that didn't work
this is the game's website page > http://www.fallensword.com/index.php?cmd=world

wOxxOmMod
§
Postat în: 20-01-2015

Well, the site dynamically modifies its layout. I've updated the script, blindly though, because I don't know what I should do in the game to bring that html element up.

§
Postat în: 20-01-2015
Editat în: 20-01-2015

Much appreciated ! that worked fine

though how can i remove classes like these together
actionListItem minion minion-0 first
actionListItem minion minion-0
actionListItem minion minion-0 last

Nevermind managed to do this by myself by repeating same codes

if (n.className == 'actionListItem minion minion-0 first')
n.parentNode.removeChild(n);
if (n.className == 'actionListItem minion minion-0')
n.parentNode.removeChild(n);
if (n.className == 'actionListItem minion minion-0 last')
n.parentNode.removeChild(n);

unless there's someway to make it shorter

Could you let me know where can i learn more about stuff you have used in that script?

wOxxOmMod
§
Postat în: 20-01-2015
Editat în: 20-01-2015
  1. for example, in the original code instead of if (n.className == 'actionListItem minion minion-0 first') use if (n.className.match(/actionListItem minion minion-0(| first| last)/)
  2. I like MDN but it's a reference, which isn't good for actually learning the stuff.
§
Postat în: 20-01-2015
Editat în: 20-01-2015

Thanks Dude now im starting to understand codes :)

wOxxOmMod
§
Postat în: 20-01-2015

good luck pwning those minions :p

Postează un raspuns

Autentifică-te pentru a posta un răspuns.