-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathHaveIAnswered.user.js
37 lines (33 loc) · 1.38 KB
/
HaveIAnswered.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
// ==UserScript==
// @name Have I Answered?
// @namespace https://stackexchange.com/users/305991/jason-c
// @version 1.0
// @description Pop up a message if you've answered a question.
// @author Jason C
// @include http*://*.stackexchange.com/questions/*
// @include http*://*.stackoverflow.com/questions/*
// @include http*://stackoverflow.com/questions/*
// @include http*://*.superuser.com/questions/*
// @include http*://superuser.com/questions/*
// @include http*://*.serverfault.com/questions/*
// @include http*://serverfault.com/questions/*
// @include http*://*.stackapps.com/questions/*
// @include http*://stackapps.com/questions/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
if (checkIfAnswered())
StackExchange.helpers.showFancyOverlay({message:'You have already posted an answer to this question.'});
function checkIfAnswered () {
var myId = StackExchange.options.user.userId;
// if user card exists on this page, the we've got an answer.
if ($(`.answercell .post-signature:last-child .user-details a[href*="/${myId}/"]`).length > 0)
return true;
// if there are no more pages of answers, then nothing left to check.
if ($('.pager-answers').length === 0)
return false;
// todo: check api, but for now, just give up...
return false;
}
})();