This repository has been archived by the owner on Oct 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27
/
dotorg-review-collector.user.js
66 lines (51 loc) · 2.16 KB
/
dotorg-review-collector.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// ==UserScript==
// @name dotorg Review Collector
// @namespace http://tampermonkey.net/
// @version 1.0
// @description Try to collect reivews from WordPress.org
// @author Andras Guseo
// @match https://wordpress.org/support/topic/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
// Your code here...
var stars = document.getElementsByClassName('dashicons-star-filled').length;
console.log(stars);
var submissionDate = document.getElementsByClassName('bbp-topic-permalink')[0].title.split(' at ');
console.log(submissionDate[0]);
var threadURL = document.getElementsByClassName('bbp-topic-permalink')[0].href;
var writer = document.getElementsByClassName('bbp-user-nicename'); //[0].innerHTML.replace('(','').replace(')','');
var author = writer[0].innerHTML.replace('(','').replace(')','');
var reply = "";
if( writer.length > 1 ) {
reply = writer[1].innerHTML.replace('(','').replace(')','');
}
console.log(author);
var title = document.getElementsByClassName('page-title')[0].innerHTML;
console.log(title);
var infoContainer = document.createElement('input');
infoContainer.id = 'infoContainerId';
infoContainer.style.width = '100%';
var dotorgHead = document.getElementById('wordpress-org');
//var popup = document.getElementsByClassName('modal-time-entry');
dotorgHead.parentNode.insertBefore(infoContainer, dotorgHead);
infoContainer.value = stars + ';out of 5 stars;' + submissionDate[0] + ';' + submissionDate[1] + ';' + author + ';' + title + ';' + reply + ';' + threadURL;
infoContainer.onclick = 'copyFunction';
infoContainer.addEventListener( 'click', function( e ) {
var target = e.target;
console.log(target.nodeName);
if ( 'input' !== target.nodeName.toLowerCase() ) {
return true;
}
var ticket_id = target.id;
console.log(ticket_id);
copyIt( ticket_id );
} );
function copyIt( element ) {
console.log( element );
var copyText = document.getElementById( element );
copyText.select();
document.execCommand( "Copy" );
}
})();