Skip to content

Commit

Permalink
Merge pull request #455 from victornpb/next
Browse files Browse the repository at this point in the history
Undiscord 5.1
  • Loading branch information
victornpb authored Mar 6, 2023
2 parents 90e66e2 + 028ca33 commit 8b254d8
Show file tree
Hide file tree
Showing 22 changed files with 3,832 additions and 19,424 deletions.
51 changes: 48 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,55 @@
# Contributing

Please do not make changes to the .js files at the root directory!
Only make changes to the change the files inside the `src/` folder, otherwise I can't merge your changes back to the project.
# Before making any changes
## Do not edit files at top

If you're unfamilliar with compiled Javascript:
Please do not make changes to the `.js` files in the top directory!
Only make changes to the files inside the `src/` folder, otherwise I can't merge your changes back to the project.

Also, do not commit changes to the `deleteDiscordMessages.user.js` file!

Do not alter the version, because I may have to change this depending on the order of things that get merged into main. So please leave it as is to avoid conflicts.

## Oddities about this project

> This is NOT your typical javascript App, so this project has a few oddities:
- Do NOT add external dependencies or libraries.
The only allowed dependencies are related things that run during build and testing.
The script itself should't import or load anything external.
The reason for this is security, if the user has to audit external packages we're doomed.

- Do NOT use Prettier.
This project has to stay fairly short in order to be auditable in a short amount of time.
For that reason some parts of the code favor compactness instead of consistency of indentation.


-------------------------------------------------------------------------------

# Building the project
# Now that you read that, this is what you do

#### Click to watch video (45 seconds):
[![Video Instructions](https://img.youtube.com/vi/AKTCvzvcPig/0.jpg)](https://www.youtube.com/watch?v=AKTCvzvcPig)
https://www.youtube.com/watch?v=AKTCvzvcPig


If you're unfamilliar with compiled Javascript, this is how you do it:

1. Clone the repository to your computer
2. Open the terminal inside the cloned directory
3. Run `npm i` to download the project dependencies
4. Run `npm start` it will automatically compile the project, when you make changes

## Testing locally

Open the URL that shows up in your console when you run `npm start` it will ask you to install a development version of Undiscord.
You need to click the update button every time you make changes in TamperMonkey, or reinstall it by opening the URL again.

You can alternatively test manually:

Copy the contents of the `deleteDiscordMessages.user.js` at the top of the repository,
and paste it directly into your browser console.

----------------------------------------------------------------

2 changes: 2 additions & 0 deletions readme.md → README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ Is prefered that _issues_ follow a certain format. If you're not familiar with b

If you believe you found a bug please file an [issue](https://github.com/victornpb/undiscord/issues), but please fill the issue template.

If you are looking to contribute please read the [CONTRIBUTING](./CONTRIBUTING.md) first.

### Copy paste version
Looking for the old Copy/Paste version? [here](https://github.com/victornpb/undiscord/wiki/Copy-paste-method)

Expand Down
20 changes: 13 additions & 7 deletions build/metadata.js → build/metadata.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// const pkg = require('../package.json');
import pkg from '../package.json';
import fs from 'fs';
const loadJSON = (path) => JSON.parse(fs.readFileSync(new URL(path, import.meta.url)));


//
// Generate metadata block with information from package.json
Expand All @@ -25,11 +26,13 @@ function generateComment(manifest) {
].join('\n');
}

export default () => {
export default function userScriptMetadataBlock() {
const pkg = loadJSON('../package.json');

const metadata = {
name: pkg.nameFull,
description: pkg.description,
version: pkg.version,
version: process.env.VERSION,
author: pkg.author,
homepageURL: pkg.homepage,
supportURL: pkg.bugs.url,
Expand All @@ -39,12 +42,15 @@ export default () => {
};

if (!production) {
metadata.name = metadata.name + ' [DEV]';
metadata.namespace = metadata.namespace + '_DEV';

delete metadata.downloadURL;
delete metadata.updateURL;
delete metadata.homepageURL;
metadata.version = new Date().toISOString();
// metadata.namespace = 'foobar';

metadata.downloadURL = metadata.updateURL = metadata.homepageURL = 'http://localhost:10001/deleteDiscordMessages.user.js';
}

return generateComment(metadata);
};
}
3 changes: 2 additions & 1 deletion build/strings-plugin.js → build/strings-plugin.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { createFilter } = require('rollup-pluginutils');
import { createFilter } from 'rollup-pluginutils';

export function string(opts = {}) {
if (!opts.include) {
Expand All @@ -12,6 +12,7 @@ export function string(opts = {}) {

transform(code, id) {
if (filter(id)) {
if (opts.transform) code = opts.transform(code, id, opts);
return {
code: 'export default (`\n'+ code + '\n`);',
map: { mappings: '' }
Expand Down
Loading

0 comments on commit 8b254d8

Please sign in to comment.