Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F6090421
ext.thanks.thank.js
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
ext.thanks.thank.js
View Options
(
function
()
{
mw
.
thanks
=
{
// Keep track of which revisions and comments the user has already thanked for
thanked
:
{
maxHistory
:
100
,
cookieName
:
'thanks-thanked'
,
/**
* Load thanked IDs from cookies
*
* @param {string} [cookieName] Cookie name to use, defaults to this.cookieName
* @return {string[]} Thanks IDs
*/
load
:
function
(
cookieName
)
{
const
cookie
=
mw
.
cookie
.
get
(
cookieName
||
this
.
cookieName
);
if
(
cookie
===
null
)
{
return
[];
}
return
unescape
(
cookie
).
split
(
','
);
},
/**
* Record as ID as having been thanked
*
* @param {string} id Thanked ID
* @param {string} [cookieName] Cookie name to use, defaults to this.cookieName
*/
push
:
function
(
id
,
cookieName
)
{
let
saved
=
this
.
load
();
saved
.
push
(
id
);
if
(
saved
.
length
>
this
.
maxHistory
)
{
// prevent forever growing
saved
=
saved
.
slice
(
saved
.
length
-
this
.
maxHistory
);
}
mw
.
cookie
.
set
(
cookieName
||
this
.
cookieName
,
escape
(
saved
.
join
(
','
)
)
);
},
/**
* Check if an ID has already been thanked, according to the cookie
*
* @param {string} id Thanks ID
* @param {string} [cookieName] Cookie name to use, defaults to this.cookieName
* @return {boolean} ID has been thanked
*/
contains
:
function
(
id
,
cookieName
)
{
return
this
.
load
(
cookieName
).
indexOf
(
id
)
!==
-
1
;
}
},
/**
* Retrieve user gender
*
* @param {string} username Requested username
* @return {jQuery.Promise} A promise that resolves with the gender string, 'female', 'male', or 'unknown'
*/
getUserGender
:
function
(
username
)
{
return
new
mw
.
Api
().
get
(
{
action
:
'query'
,
list
:
'users'
,
ususers
:
username
,
usprop
:
'gender'
}
)
.
then
(
(
result
)
=>
(
result
.
query
.
users
[
0
]
&&
result
.
query
.
users
[
0
].
gender
)
||
'unknown'
,
()
=>
'unknown'
);
}
};
}()
);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Oct 5 2026, 20:11 (6 w, 1 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
4b/39/4add06cd9fffe813c4e4ccc0bbeb
Default Alt Text
ext.thanks.thank.js (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment