Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@ Thanks for contributing! 🦋🙌
- [](# "prevent-pr-commit-link-loss") [Suggests fixing your PR Commit links before commenting. GitHub has a bug that causes these link to appear as plain commit links, without association to the PR.](https://user-images.githubusercontent.com/1402241/82131169-93fd5180-97d2-11ea-9695-97051c55091f.gif)
- [](# "align-repository-header") [Aligns the repository header to the repository content on wide screens.](https://user-images.githubusercontent.com/1402241/86574587-587f3800-bf76-11ea-9961-5c25cdb6e357.gif)
- [](# "linkify-user-edit-history-popup") [Linkifies the username in the edit history popup.](https://user-images.githubusercontent.com/1402241/88917988-9ebb7480-d260-11ea-8690-0a3440f1ebbc.png)
- [](# "prevent-duplicate-pr-submission") [Avoids creating duplicate PRs when mistakenly clicking "Create pull request" more than once.](https://user-images.githubusercontent.com/16872793/89589967-e029c200-d814-11ea-962b-3ff1f6236781.gif)

<!-- Refer to style guide above. Keep this message between sections. -->

Expand Down
29 changes: 29 additions & 0 deletions source/features/prevent-duplicate-pr-submission.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import delegate from 'delegate-it';
import * as pageDetect from 'github-url-detection';

import features from '.';

let previousSubmission = 0;

function preventSubmit(event: delegate.Event<MouseEvent, HTMLButtonElement>): void {
if (Date.now() - previousSubmission < 1000) {
event.preventDefault();
}

previousSubmission = Date.now();
}

function init(): void {
delegate(document, '#new_pull_request', 'submit', preventSubmit);
}

void features.add({
id: __filebasename,
description: 'Avoids creating duplicate PRs when mistakenly clicking "Create pull request" more than once.',
screenshot: 'https://user-images.githubusercontent.com/16872793/89589967-e029c200-d814-11ea-962b-3ff1f6236781.gif'
}, {
include: [
pageDetect.isCompare
],
init
});
1 change: 1 addition & 0 deletions source/refined-github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ import './features/vertical-front-matter';
import './features/use-first-commit-message-for-new-prs';
import './features/linkify-user-edit-history-popup';
import './features/cleanup-repo-filelist-actions';
import './features/prevent-duplicate-pr-submission';

// Add global for easier debugging
(window as any).select = select;