1+ // ==UserScript==
2+ // @name Accept Payment
3+ // @namespace http://tampermonkey.net/
4+ // @version 0.1
5+ // @description Gets all pendent payments and accepts them
6+ // @author fiusen
7+ // @icon https://www.google.com/s2/favicons?domain=paypal.com
8+ // @match https://www.paypal.com/myaccount/activities/*
9+ // ==/UserScript==
10+
11+ function getAncestors ( node ) {
12+ var ancestors = [ ] ;
13+ while ( node . parentNode ) {
14+ ancestors . push ( node . parentNode . className ) ;
15+ node = node . parentNode ;
16+ }
17+ return ancestors ;
18+ }
19+
20+
21+ function getAcceptElements ( ) {
22+ var aTags = document . getElementsByClassName ( "ppvx_row___2-7-9" ) ;
23+ var foundList = [ ] ;
24+
25+ for ( var i = 0 ; i < aTags . length ; i ++ ) {
26+ if ( aTags [ i ] . className == "ppvx_row___2-7-9" ) {
27+ foundList . push ( aTags [ i ] ) ;
28+ }
29+ }
30+
31+ return foundList ;
32+ }
33+
34+ function getDescendants ( node ) {
35+ var list = [ ] , desc = node , checked = false , i = 0 ;
36+ do {
37+ checked || ( list [ i ++ ] = desc ) ;
38+ desc =
39+ ( ! checked && desc . firstChild ) ||
40+ ( checked = false , desc . nextSibling ) ||
41+ ( checked = true , desc . parentNode ) ;
42+ } while ( desc !== node ) ;
43+ return list ;
44+ }
45+
46+ ( async ( ) => {
47+ if ( await GM . getValue ( "running" ) ) close ( ) ;
48+ var index = 0 ;
49+ GM . setValue ( "running" , true ) ;
50+ var values = [ ] ;
51+ var ancestors = getDescendants ( getAcceptElements ( ) [ 0 ] ) ;
52+ for ( var j = 0 ; j < ancestors . length ; j ++ ) {
53+ let o = ancestors [ j ] ;
54+ if ( typeof ( o . className ) === "string" && o . className . includes ( "list_item" ) ) {
55+ let id = o . className . replace ( "list_item js_transactionItem-" , "" ) ;
56+ let href = "https://www.paypal.com/activity/actions/acceptdeny/edit/" + id ;
57+
58+ window . open ( href , '_blank' ) . focus ( ) ;
59+ await new Promise ( r => setTimeout ( r , 16000 ) ) ; // so it doesnt break bc of the captcha
60+ }
61+ }
62+ } ) ( ) ;
0 commit comments