Skip to content

Instantly share code, notes, and snippets.

@silvasur
Last active December 12, 2023 04:51
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save silvasur/227c01524ffa5eeff74032d95fff8cc5 to your computer and use it in GitHub Desktop.
Save silvasur/227c01524ffa5eeff74032d95fff8cc5 to your computer and use it in GitHub Desktop.
Userscript to hide Wikipedia donation nagscreen
// ==UserScript==
// @name Hide wikipedia donation nagscreen
// @description Wikimedia, I already give you money, leave me alone!
// @version 3
// @grant GM.setValue
// @grant GM.getValue
// @match https://*.wikipedia.org/*
// ==/UserScript==
(async function() {
console.log("hello")
var styles = `
.cn-fundraising, .cn-frthankyou {
display: none;
}
#mw-page-base {
padding-top: 0 !important;
}
#mw-head {
top: 0 !important;
}
#mw-panel {
top: 0 !important;
}
`
let agreed = await GM.getValue("agreed");
console.log(agreed);
if (agreed === undefined) {
agreed = confirm("This userscript is meant for people who already donate regularly to Wikipedia. Do you donate regularly or promise to do so?")
await GM.setValue("agreed", agreed);
}
if (!agreed)
return;
document.head.appendChild((function(){
let s = document.createElement("style");
s.innerText = styles;
return s;
})());
})();
@RivenSkaye
Copy link

RivenSkaye commented Sep 12, 2023

Can I request the file extension to be changed to .user.js so that tampermonkey picks up the script for automatically installing it when opening the raw?

The @include can also use a small update to @match. Should still function as intended with this pattern

@amitsingh-007
Copy link

This works great, thanks

@silvasur
Copy link
Author

Can I request the file extension to be changed to .user.js so that tampermonkey picks up the script for automatically installing it when opening the raw?

The @include can also use a small update to @match. Should still function as intended with this pattern

Good idea, have change the file name. Also sorry for late reply :/

@RivenSkaye
Copy link

Don't worry about reply times, it's nit a high priority issue. If you have more user scripts, making a single repo containing all of them would be a nice idea.

Grease- and Tampermonkey should both pick up raw.*git*.*/**/*user.js patterns to allow installing them on the fly, and the @match preference for them is also a fairly recent change. I only suggested it because it still works really well, and it'd be nice to keep it that way for as long as possible

@silvasur
Copy link
Author

Had the time ro investigate now, and have changed it from @include to @match.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment