pstein Posted March 9 Share Posted March 9 (edited) How can I select all SPAN elements in current webpage which contain a property "foobar"? The assigned value is unimportant. So elements like the following should be matched: <span aaa="bbb" foobar="23452345" .....>...</span> I tried: $('span[foobar^=""]').remove(); but it didn't work Edited March 9 by pstein Link to comment Share on other sites More sharing options...
dsonesuk Posted March 9 Share Posted March 9 (edited) That will look for attribute with empty string value. Try $('span').attr('foobar').remove(); Edited March 9 by dsonesuk Link to comment Share on other sites More sharing options...
pstein Posted March 14 Author Share Posted March 14 (edited) Your solution is NOT working. Lets see a simplified example: https://www.makeuseof.com/how-to-take-screenshots-on-android-when-the-app-doesnt-allow-it/ I want to get rid of an advertising block on the right (see attached snapshot). which starts with: <div id="K84X2hsVZN" data-ub-carousel="true" Therefor I setup a Greasemonkey script like // ==UserScript== // @name ChangeLayoutMakeuseof // @namespace nsChangeLayoutMakeuseof // @description Change Layout makeuseof.com // @match https://*.makeuseof.com/* // @exclude-match https://*.makeuseof.com/ // @exclude-match https://*.makeuseof.com/category/* // @version 2.14.1 // @grant GM_addStyle // @require http://code.jquery.com/jquery-latest.js // ==/UserScript== $('div').attr('data-ub-carousel').remove(); setTimeout(function(){ $('div').attr('data-ub-carousel').remove(); }, 5000); After adding the user script and reloading the webpage, the ad persist. Any other suggestion? https://s20.directupload.net/images/240314/gm2z76xs.png Edited March 14 by pstein Link to comment Share on other sites More sharing options...
dsonesuk Posted March 16 Share Posted March 16 As it is a carousel it probably is looping to add a new ad at a set time. So it might be better to hide than remove. As your script only runs once after 5sec it catch first one only, unless you use setInterval then it will repeat every 5 sec. To reduce repeating loops check this element exists by checking length. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now