NoTrack: Option to keep analytics, improve patches
This commit is contained in:
parent
7af733c7c8
commit
5bc20ba162
1 changed files with 19 additions and 5 deletions
|
@ -16,17 +16,31 @@
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { definePluginSettings } from "@api/Settings";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import definePlugin from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
|
|
||||||
|
const settings = definePluginSettings({
|
||||||
|
disableAnalytics: {
|
||||||
|
type: OptionType.BOOLEAN,
|
||||||
|
description: "Disable Discord's tracking (analytics/'science')",
|
||||||
|
default: true,
|
||||||
|
restartNeeded: true
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
export default definePlugin({
|
export default definePlugin({
|
||||||
name: "NoTrack",
|
name: "NoTrack",
|
||||||
description: "Disable Discord's tracking ('science'), metrics and Sentry crash reporting",
|
description: "Disable Discord's tracking (analytics/'science'), metrics and Sentry crash reporting",
|
||||||
authors: [Devs.Cyn, Devs.Ven, Devs.Nuckyz, Devs.Arrow],
|
authors: [Devs.Cyn, Devs.Ven, Devs.Nuckyz, Devs.Arrow],
|
||||||
required: true,
|
required: true,
|
||||||
|
|
||||||
|
settings,
|
||||||
|
|
||||||
patches: [
|
patches: [
|
||||||
{
|
{
|
||||||
find: "AnalyticsActionHandlers.handle",
|
find: "AnalyticsActionHandlers.handle",
|
||||||
|
predicate: () => settings.store.disableAnalytics,
|
||||||
replacement: {
|
replacement: {
|
||||||
match: /^.+$/,
|
match: /^.+$/,
|
||||||
replace: "()=>{}",
|
replace: "()=>{}",
|
||||||
|
@ -44,11 +58,11 @@ export default definePlugin({
|
||||||
replacement: [
|
replacement: [
|
||||||
{
|
{
|
||||||
match: /this\._intervalId=/,
|
match: /this\._intervalId=/,
|
||||||
replace: "this._intervalId=undefined&&"
|
replace: "this._intervalId=void 0&&"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
match: /(increment\(\i\){)/,
|
match: /(?:increment|distribution)\(\i(?:,\i)?\){/g,
|
||||||
replace: "$1return;"
|
replace: "$&return;"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue