-
Notifications
You must be signed in to change notification settings - Fork 34
/
NoUserIdShareLinks.user.js
57 lines (48 loc) · 1.75 KB
/
NoUserIdShareLinks.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// ==UserScript==
// @name No User Id in Share Links
// @description Remove your referral user id when copying a post share link
// @homepage https://github.com/samliew/SO-mod-userscripts
// @author Samuel Liew
// @version 2.0.13
//
// @match https://*.stackoverflow.com/*
// @match https://*.serverfault.com/*
// @match https://*.superuser.com/*
// @match https://*.askubuntu.com/*
// @match https://*.mathoverflow.net/*
// @match https://*.stackapps.com/*
// @match https://*.stackexchange.com/*
// @match https://stackoverflowteams.com/*
//
// @exclude https://api.stackexchange.com/*
// @exclude https://data.stackexchange.com/*
// @exclude https://contests.stackoverflow.com/*
// @exclude https://winterbash*.stackexchange.com/*
// @exclude */tour
//
// @require https://raw.githubusercontent.com/samliew/SO-mod-userscripts/master/lib/se-ajax-common.js
// @require https://raw.githubusercontent.com/samliew/SO-mod-userscripts/master/lib/common.js
// ==/UserScript==
/* globals StackExchange */
/// <reference types="./globals" />
'use strict';
function stripUserIds() {
// Strip user ids from the link itself
const sharelinks = $('.js-share-link').not('.js-no-userid').addClass('js-no-userid').attr('href', (i, v) => v.replace(/(\/\d+)\/\d+/, '$1'));
// Strip user ids from the popups
sharelinks.next().find('input').val((i, v) => v.replace(/(\/\d+)\/\d+/, '$1'));
}
// Append styles
addStylesheet(`
.js-share-link + .s-popover .js-subtitle {
display: none;
}
`); // end stylesheet
// On script run
(function init() {
stripUserIds();
// When new stuff is loaded
$(document).ajaxComplete(function (event, xhr, settings) {
stripUserIds();
});
})();