Raiffeisen fixes
Applies fixes this bank hasn't yet realized are useful
This script is marked as "external"This script was commisioned by someone else, and I will not check if it works. If it breaks,
contact me Click here to install
Browse More Scripts
// ==UserScript==
// @name Raiffeisen fixes
// @namespace d944b6818c7b18d251781080906cb84b67eea47b
// @version 0.2
// @description Applies fixes this bank hasn't yet realized are useful
// @author /u/AyrA_ch
// @match https://ebanking.raiffeisen.ch/*
// @grant none
// @external true
// ==/UserScript==
// Version History
// 0.2 - Add eBill fixes
// 0.1 - Date Fixes
(function ($) {
'use strict';
//Selector for "Open eBill" button
var EBILL_SELECTOR = "[data-ng-show='account.ACCO_ID']";
//URL for eBill System
var EBILL_URL = "https://ebill.raiffeisen.ch/ebill-portal/ui/payment-slips/by-due-date";
//Hour after which we can't schedule same day payments anymore
var DEADLINE_HOURS = 10;
//Days of week we can make payments (0=su, ..., 6=sa)
var VALID_DAYS = [1, 2, 3, 4, 5];
//True if we have a hnalder scheduled or executing
var handling = false;
var fixEbill = function () {
return false;
var btn = $(EBILL_SELECTOR);
if (btn) {
var x = document.createElement("button");
x.setAttribute("class", btn.getAttribute("class"));
x.setAttribute("type", "button");
x.innerText = btn.innerText;
btn.parentNode.insertBefore(x, btn);
btn.remove();
x.addEventListener("click", function (e) {
var a = document.createElement("a");
a.href = EBILL_URL;
a.target = "_blank";
a.click(e);
});
console.info("eBill button replaced");
}
};
var setDate = function () {
if (!handling) {
handling = true;
//Using setTimeout prevents the handler from running very quickly in succession
//if multiple changes happened to the document.
setTimeout(function () {
var e = $("#datepicker_ausfuehrungsdatum");
if (e) {
//Current value. Only needed for reporting
var now = e.value;
//Get current date
var d = new Date();
//Check if we are past the time where we can schedule for same-day payments
if (d.getHours() >= DEADLINE_HOURS) {
//Next day
d.setDate(d.getDate() + 1);
}
//Skip over invalid days
while (VALID_DAYS.indexOf(d.getDay()) < 0) {
d.setDate(d.getDate() + 1);
}
//Build value with two digit numbers where needed
e.value = [d.getDate(), d.getMonth() + 1, d.getFullYear()].map(function (v) {
return v < 10 ? "0" + v : v;
}).join('.');
//Trigger angular events because the dev was stupid
angular.element(e).trigger("keyup");
angular.element(e).trigger("change");
//Report
console.log("fixed date:", now, "-->", e.value);
} else {
//Date field not found
console.debug("No date to fix");
}
handling = false;
}, 100);
}
};
//Run the setDate function on each change to the site
var observer = new MutationObserver(function () {
setDate();
fixEbill();
});
var config = {
subtree: true,
attributes: true,
childList: true,
characterData: false
};
observer.observe(document.body, config);
})(document.querySelector.bind(document));
/*
LICENSE:
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
The full license text can be found here: http://creativecommons.org/licenses/by-nc-sa/4.0/
The link has an easy to understand version of the license and the full license text.
DISCLAIMER:
THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
THE POSSIBILITY OF SUCH DAMAGE.
*/
This script is marked as "external".
This means that the script was developed for someone else.
Because I don't use the script myself I will not know when it breaks.
If it breaks,
contact me for a fix.
User Script Managers
A userscript manager is the browser extension that injects scripts into websites
to change their behavior to your liking.
Recommendation
All scripts on this site have been developed and tested with Tampermonkey on firefox.
Try other browsers and other script managers at your own risk.
No script should use firefox or chrome specific features,
which means they should also work in other modern browsers.
If you prefer, you can use greasemonkey.
Get Tampermonkey,
Get Greasemonkey (Firefox only)
Script Installation
Once you have obtained a user script manager,
clicking on the install button will pop up an installation prompt.
To allow script manager detection,
you can install this helper script.
It's not necessary but simplifies your future visits to this site.
Script Installation
We detected, that you have a script manager installed and active.
Click the "Install Script" button to obtain the script.