/
halt_dickish_behavior.js
139 lines (122 loc) · 4.96 KB
/
halt_dickish_behavior.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
/* Fight For Your Right To Pay With A Credit Card
* ================================================
*
* Few things are valued more highly in modern society than the ability
* to pay with a credit card. While this fact unsurprisingly suits most
* businesses perfectly well, it runs contrary to the interests of the
* web's largest payment provider, which seeks to minimize the
* transaction costs it pays to the card networks.
*
* In the quest for increased profits, the leadership of said company,
* (which rhymes with "papal" if you are given to slight mispronunciation
* and are fine with heavily redundant rhymes) tried every method of
* persuasion it could, pitting mildly misleading charts and
* calls-to-action against eachother in an attempt to convince the
* consumer to put down the plastic and pick up a checkbook.
*
* But when A/B tests didn't work, they turned to wanton trickery and
* other crude tactics, like 3-click payment method selection, making it
* virtually impossible to pay the God-given way. As things stand today,
* if you want to pay with a credit card, you prettymuch have to fight
* for it.
*
* You can either wait until President Ron Paul is in office and
* everything can be paid for with Bitcoin, OR you can install this
* Chrome extension, which will fight for you.
*
* But don't take my word for it, listen to Bob the Center-Left Cow:
* ______________________________________
* < Moderately decent UX before profits! >
* --------------------------------------
* \ ^__^
* \ (oo)\_______
* (__)\ )\/\
* ||----w |
* || ||
*
*
* Comments/lawsuits: @BenRegenspan
*
*/
/* TODO: il8n on various detection strings, like "Bill Me Later",
* this assumes English-only Paypal interface for now.
*
* Also, ensure that this actually works when the user has a bank account
* set up (only tested with Bill Me Later).
*/
$(function () {
'use strict';
function detectInitialPaymentForm(callback) {
/* Detect whether the user is on the first step
* of the payment process and annoying defaults
* are showing. Call callback if so.
*/
callback = callback || function () {};
function checkForAnnoyingDefaults() {
var fundingSelector = $('#funding-mix');
// Make sure there is some reference to the annoying
// default payment methods we're trying to avoid
var badOptions = [
'Bill Me Later',
'Instant Transfer',
'Bank Account', // TODO: verify this is correct string
'Checking Account' // TODO: verify this is correct string
];
var html = fundingSelector.html();
for (var i = 0, ilen = badOptions.length; i < ilen; i++) {
if (html.indexOf(badOptions[i]) > -1) {
return true;
}
}
return false;
}
// Ensure we're on the initial "express checkout" step
if (window.location.href.indexOf('cmd=_express-checkout') === 0) {
return false;
}
// We need to wait for the funding selector to show,
// so poll for it.
var interval = window.setInterval(function () {
if ($('#funding-mix').length) {
// We found the funding selector!
window.clearInterval(interval);
if (checkForAnnoyingDefaults()) {
callback();
}
}
}, 50);
}
function detectPaymentSelectionForm(callback) {
/* Detect whether user is on the form that
* actually permits selecting a payment method, execute
* callback if so */
if ($('#fieldRow_1').length &&
$('#fieldRow_2').length) {
callback();
}
return false;
}
detectInitialPaymentForm(function () {
// The user is on the stupid first payment form page
// where the preferred payment method should be,
// but isn't.
// Trigger Paypal taking user to a whole new
// page just to switch the funding option.
// (This is the kind of thing that happens when you
// optimize for revenue at the expense of UX):
$('#funding_select').click();
});
detectPaymentSelectionForm(function () {
// The user is on the payment step where, after waiting
// for the page to load (possibly with intentionally slow
// pageload time, because I wouldn't put it past these
// people) he or she is actually permitted to choose how
// to pay.
// Select the first card on the form:
$('.Card:first input').attr('checked', 'checked');
if ($('.Card').length == 1)
$('#continue').click();
// For safety's sake, don't do anything else for now.
// It's up to user to submit.
});
});