bypass-paywalls-firefox-clean/contentScript_once.js

37 lines
1.1 KiB
JavaScript
Raw Normal View History

//"use strict";
if (matchDomain('gitlab.com')) {
2022-03-17 19:39:21 +01:00
window.setTimeout(function () {
let bio = document.querySelector('div.profile-user-bio');
if (bio) {
let split = bio.innerText.split(/(https:[\w\-/.]+)|\|/g).filter(x => x && x.trim());
bio.innerText = '';
for (let part of split) {
let elem;
if (part.startsWith('https')) {
elem = document.createElement('a');
elem.innerText = part;
elem.href = part;
elem.appendChild(document.createElement('br'));
} else {
elem = document.createElement('b');
elem.appendChild(document.createTextNode(part));
if (!part.includes(':'))
elem.appendChild(document.createElement('br'));
}
bio.appendChild(elem);
}
}
}, 1000);
2021-09-05 18:47:28 +02:00
}
function matchDomain(domains, hostname) {
var matched_domain = false;
if (!hostname)
hostname = window.location.hostname;
if (typeof domains === 'string')
domains = [domains];
domains.some(domain => (hostname === domain || hostname.endsWith('.' + domain)) && (matched_domain = domain));
return matched_domain;
}