0

I made a userscript that works on https://stackoverflow.com/questions/* which removes Stackoverflows' ads (It works Well). But when I click on "read more comments" for a question form or interact with some buttons of the question, the website scrolls to the top not enabling me to read more comment or etc...

I have tried to disable the userscript after that the page acts normally, but when I re-enable the script back the webpage does not interact.

// ==UserScript==
// @name         NoStackAds
// @namespace    http://tampermonkey.net/
// @version      1.1
// @require      http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js
// @description  try to take over the stack!
// @author       me
// @match        https://stackoverflow.com/questions/*
// @grant        none
// ==/UserScript==


$(document).ready(function(){
    $(".everyonelovesstackoverflow.everyoneloves__top-leaderboard").remove();
});

When I enable the script the ads disappear (as expected). But the web page becomes no more normal.

I am not sure what are the best tags to be used.

Makyen
  • 31,849
  • 12
  • 86
  • 121
Joe
  • 879
  • 3
  • 14
  • 37
  • 1
    That is not the complete userscript, nor is a [mre]. **Add one or both to the question.** In general, if using `@grant none` (the default), don't `@require` jQuery. – Brock Adams Jun 10 '19 at 18:28
  • @BrockAdams what did you mean by don't `@require` jQuery? – Joe Jun 10 '19 at 18:34
  • See https://stackoverflow.com/questions/12146445/jquery-in-greasemonkey-1-0-conflicts-with-websites-using-jquery. This question is now a duplicate of that one. – Brock Adams Jun 10 '19 at 18:36
  • 1
    *Please* don't load jQuery into **every** SO page unless you **need** to. jQuery is 85kiB of minimized code. This is a significant burden with which to saddle *every single SO question page*. What of those of us who have 100's of tabs open? What you are really using it for is the convenience of saving a hundred, or so, characters in your own code by not using vanilla JavaScript. Doing so is a *very* poor trade-off from your user's point of view. Also, this is *far* better implemented by just adding a CSS rule that applies `display: none`, with `!important` if needed. – Makyen Jun 10 '19 at 19:08
  • @Makyen I really appreciate that advice, I am going to read more about **Vanilla JS** because it seems the solution. The link of the possible duplicate question didn't help me understand the problem other than that my jquery makes trouble when loading SO javascript together. – Joe Jun 11 '19 at 02:07

0 Answers0