-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpf_post_link.user.js
More file actions
40 lines (31 loc) · 1.27 KB
/
pf_post_link.user.js
File metadata and controls
40 lines (31 loc) · 1.27 KB
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
38
39
40
// ==UserScript==
// @name ProgrammersForumPostLink
// @namespace http://programmersforum.ru/
// @version 1.0
// @description adds button to copy post url
// @author Alex P
// @include *programmersforum.ru/*
// @grant GM_setClipboard
// @grant GM_addStyle
// @downloadURL https://github.com/AlexP11223/ProgForumRuUserscripts/raw/master/pf_post_link.user.js
// ==/UserScript==
(function() {
'use strict';
if (window.postLinkInitialized)
return;
window.postLinkInitialized = true;
GM_addStyle('.link-popup { font-weight: bold; margin-right: 8px; }');
const BASE_URL = 'https://programmersforum.ru/';
$.each($('a[id^="postcount"]'), (i, oldPostLink) => {
const href = $(oldPostLink).attr('href');
const container = $(oldPostLink).parent();
const postLink = $('<a href="' + href + '">ссылка</a>').prependTo(container);
postLink.click(e => {
e.preventDefault();
GM_setClipboard(BASE_URL + href);
const popup = $('<span class="link-popup" style="display: none;">ссылка скопирована в буфер обмена</span>').prependTo(container);
popup.fadeIn();
popup.delay(2500).fadeOut();
});
});
})();