Commit 90c8dc14 authored by  JosephK's avatar JosephK

Default colors as a setting + fix adblock detection ?

parent 837cd144
Pipeline #45007 passed with stages
in 1 minute
......@@ -15,15 +15,15 @@
<h2>Examples</h2>
<h3>Leaderboard (728 x 90)</h3>
<div class="text-center">
<script type="text/javascript" src="/sense3/sense3.js" data-sense3="728x90;;;vangogh"></script>
<script type="text/javascript" src="/sense3/sense3.js" data-sense3="728x90;;;wikipedia"></script>
<script type="text/javascript" src="sense3.js" data-sense3="728x90;;;vangogh"></script>
<script type="text/javascript" src="sense3.js" data-sense3="728x90;;;wikipedia"></script>
<pre><code>&lt;script type="text/javascript" src="sense3.js" data-sense3="728x90"&gt;&lt;/script&gt;</code></pre>
</div>
<h3>Medium rectangle (350 x 200)</h3>
<div class="text-center">
<script type="text/javascript" src="sense3.js" data-sense3="300x250;;;vangogh"></script>
<script type="text/javascript" src="/sense3/sense3.js" data-sense3="300x250;;;wikipedia"></script>
<script type="text/javascript" src="sense3.js" data-sense3="300x250;;;wikipedia"></script>
<pre><code>&lt;script type="text/javascript" src="sense3.js" data-sense3="300x250"&gt;&lt;/script&gt;</code></pre>
</div>
......
......@@ -194,6 +194,7 @@
<script type="text/javascript" src="bowser.min.js"></script>
</head>
<body>
<div id="bottomAd" style="font-size: 2px;">&nbsp;</div>
<script type="text/javascript" src="sense3.js"></script>
</body>
</html>
......@@ -2,6 +2,7 @@
(function sense3() {
let sense3Baseurl = '';
const defaultColors = ['#FFFFFF', '#963425', '#333333', '#757575', '#963425', '#CCCCCC'];
const i18n = {
en: {
close: 'Close',
......@@ -9,6 +10,8 @@
os: 'System',
browser: 'Browser',
adblock: 'Adblock',
enabled: 'Enabled',
disabled: 'Disabled ?',
ua: 'User-Agent',
referrer: 'Referrer',
banner: 'Banner',
......@@ -33,6 +36,8 @@
os: 'Plateforme',
browser: 'Navigateur',
adblock: 'Adblock',
enabled: 'Actif',
disabled: 'Inactif ?',
ua: 'User-Agent',
referrer: 'Référent',
banner: 'Bannière',
......@@ -224,7 +229,7 @@
},
// Adblock
ublock: {
condition: !s.is.adblock(),
condition: (!s.is.adblock() && !bowser.firefox && !s.is.bad('chrome')),
format: ['txt', '300x250', '728x90'],
link: { xx: 'https://github.com/gorhill/uBlock' },
text: {
......@@ -404,7 +409,7 @@
let [format, tags, colors, id] = scripts[i].getAttribute('data-sense3').split(';');
format = format || '300x250';
tags = tags || '';
colors = colors || '#FFFFFF,#963425,#333333,#757575,#963425,#CCCCCC';
colors = colors || defaultColors.join();
id = id || '';
const [w, h] = format.split('x');
......@@ -594,7 +599,7 @@
<tr>
<td><img src="img/icons/os/${img.os}" alt="" /><br>${bowser.osname} ${(bowser.osversion || '')}</td>
<td><img src="img/icons/browsers/${img.browser}" alt="" /><br>${bowser.name} ${(bowser.version || '')}</td>
<td><img src="img/icons/ublock/${img.adblock}" alt="" /></td>
<td><img src="img/icons/ublock/${img.adblock}" alt="" /><br>${(s.is.adblock() ? i18n[lg].enabled : i18n[lg].disabled)}</td>
<tr>
</tbody>
</table>
......@@ -640,6 +645,7 @@
const html = `
<form class="form-horizontal" id="sense3_generator" onsubmit="document.getElementById('sense3_code').className = ''; sense3Generate(); return false;">
<input type="hidden" id="sense3Baseurl" value="${sense3Baseurl}">
<input type="hidden" id="sense3DefaultColors" value="${defaultColors.join()}">
<fieldset id="banner">
<legend>${i18n[lg].banner}</legend>
<div class="row">
......@@ -678,19 +684,19 @@
<div class="form-group">
<label for="bg" class="col-sm-4 control-label">${i18n[lg].background}</label>
<div class="col-sm-8">
<input id="bg" value="#ffffff" class="form-control" type="color">
<input id="bg" value="${defaultColors[0]}" class="form-control" type="color">
</div>
</div>
<div class="form-group">
<label for="h1" class="col-sm-4 control-label">${i18n[lg].text1}</label>
<div class="col-sm-8">
<input id="h1" value="#963425" class="form-control" type="color">
<input id="h1" value="${defaultColors[1]}" class="form-control" type="color">
</div>
</div>
<div class="form-group">
<label for="h2" class="col-sm-4 control-label">${i18n[lg].text2}</label>
<div class="col-sm-8">
<input id="h2" value="#333333" class="form-control" type="color">
<input id="h2" value="${defaultColors[2]}" class="form-control" type="color">
</div>
</div>
</div>
......@@ -698,19 +704,19 @@
<div class="form-group">
<label for="p" class="col-sm-4 control-label">${i18n[lg].link}</label>
<div class="col-sm-8">
<input id="p" value="#757575" class="form-control" type="color">
<input id="p" value="${defaultColors[3]}" class="form-control" type="color">
</div>
</div>
<div class="form-group">
<label for="btn" class="col-sm-4 control-label">${i18n[lg].button}</label>
<div class="col-sm-8">
<input id="btn" value="#963425" class="form-control" type="color">
<input id="btn" value="${defaultColors[4]}" class="form-control" type="color">
</div>
</div>
<div class="form-group">
<label for="bdr" class="col-sm-4 control-label">${i18n[lg].border}</label>
<div class="col-sm-8">
<input id="bdr" value="#CCCCCC" class="form-control" type="color">
<input id="bdr" value="${defaultColors[5]}" class="form-control" type="color">
</div>
</div>
</div>
......@@ -819,13 +825,7 @@
},
adblock() {
let spoof = document.createElement('div');
spoof.setAttribute('id', 'bottomAd');
spoof.innerHTML = '&nbsp;';
spoof.style.cssText = 'font-size: 2px;';
document.getElementsByTagName('body')[0].appendChild(spoof);
spoof = document.getElementById('bottomAd');
const spoof = document.getElementById('bottomAd');
let blockedSpoof = false;
......@@ -836,7 +836,6 @@
} else if ((typeof spoof.clientHeight) !== 'undefined' && spoof.clientHeight === 0) {
blockedSpoof = true;
}
// spoof.parentNode.removeChild(spoof);
return blockedSpoof;
},
......@@ -925,6 +924,7 @@
function sense3Generate() { // eslint-disable-line no-unused-vars
const sense3Baseurl = $('#sense3Baseurl').val() || '';
const sense3DefaultColors = $('#sense3DefaultColors').val() || '';
const force = $('#force').val() || '';
const tags = []; const colors = [];
if (force === '') {
......@@ -938,7 +938,7 @@ function sense3Generate() { // eslint-disable-line no-unused-vars
let params = $('#format').val();
params = `${params};${tags.join()};${colors.join()};${force}`;
params = params.replace('#ffffff,#963425,#333333,#757575,#963425,#cccccc', '').replace(/(;+)$/, '');
params = params.replace(sense3DefaultColors, '').replace(/(;+)$/, '');
const code = `<script type="text/javascript" src="${sense3Baseurl}sense3.js" data-sense3="${params}"></script>`;
$('#sense3_generator code').text(code);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment