Commit e1ad51a7 authored by  JosephK's avatar JosephK

Conditions shortcuts

parent e33c5aed
......@@ -102,13 +102,13 @@
<div class="text-center col-sm-6">
<h5>Peertube</h5>
<script type="text/javascript" src="sense3.js" data-sense3="300x250;wikipedia;#FFFFFF,#F1680D,#616161,#757575,#F1680D,#F1680D"></script>
<pre><code>data-sense3="728x90;;#FFFFFF,#F1680D,#616161,#757575,#F1680D,#F1680D"</code></pre>
<pre><code>data-sense3="300x250;;#FFFFFF,#F1680D,#616161,#757575,#F1680D,#F1680D"</code></pre>
</div>
<div class="text-center col-sm-6">
<h5>Framaporn</h5>
<script type="text/javascript" src="sense3.js" data-sense3="300x250;wikipedia;#FFF,#EF7896,#757776,#757575,#EF7896,#EF7896"></script>
<pre><code>data-sense3="728x90;;#FFF,#EF7896,#757776,#757575,#EF7896,#EF7896"</code></pre>
<pre><code>data-sense3="300x250;;#FFF,#EF7896,#757776,#757575,#EF7896,#EF7896"</code></pre>
</div>
<h4>Examples from Google Adsense</h4>
......
......@@ -77,45 +77,42 @@
*/
// Referrer
dioGafam: {
condition: (s.is.referrer('facebook.com') || s.is.referrer('google.com') ||
s.is.referrer('amazon.com') || s.is.referrer('bing.com') ||
bowser.chrome || bowser.safari || bowser.mac ||
bowser.windows || bowser.ios),
condition: s.is.bad('gafam'),
format: ['png', '300x250'],
link: { xx: 'https://degooglisons-internet.org/' },
text: { en: ['GAFAM', 'We <3 your data !'] },
tags: ['referrer', 'facebook', 'degooglisons', 'google', 'apple', 'microsoft', 'amazon', 'gafam'],
},
dioAmazon: {
condition: s.is.referrer('amazon.com'),
condition: s.is.bad('amazon'),
format: ['png', '300x250'],
link: { xx: 'https://degooglisons-internet.org/' },
text: { fr: ['Amazon', 'très méchant'] },
tags: ['referrer', 'amazon', 'degooglisons', 'gafam'],
},
dioFacebook: {
condition: s.is.referrer('facebook.com'),
condition: s.is.bad('facebook'),
format: ['png', '300x250'],
link: { xx: 'https://degooglisons-internet.org/' },
text: { en: ['Facebook', 'is watching you…'] },
tags: ['referrer', 'facebook', 'degooglisons', 'gafam'],
},
dioGoogle: {
condition: (s.is.referrer('google.com') || bowser.chrome),
condition: s.is.bad('google'),
format: ['png', '300x250'],
link: { xx: 'https://degooglisons-internet.org/' },
text: { en: ['Warning', 'Don’t feed the Google'] },
tags: ['referrer', 'google', 'degooglisons', 'gafam'],
},
dioMicrosoft: {
condition: (s.is.referrer('bing.com') || bowser.windows),
condition: s.is.bad('microsoft'),
format: ['png', '300x250'],
link: { xx: 'https://degooglisons-internet.org/' },
text: { en: ['Microsoft', 'Do you need a backdoor ?'] },
tags: ['referrer', 'microsoft', 'degooglisons', 'gafam'],
},
diaspora: {
condition: s.is.referrer('facebook.com'),
condition: s.is.bad('facebook'),
format: ['txt', '300x250', '728x90'],
link: {
en: 'https://diasporafoundation.org/',
......@@ -128,7 +125,7 @@
tags: ['referrer', 'facebook', 'social'],
},
mastodon: {
condition: s.is.referrer('twitter.com'),
condition: s.is.bad('twitter'),
format: ['txt', '300x250', '728x90'],
colors: '#282c37,#9baec8,#d9e1e8,#2b90d9,#2b90d9,#9baec8',
link: { xx: 'https://joinmastodon.org' },
......@@ -140,14 +137,34 @@
},
// Browser
chrome: {
condition: (bowser.chrome || bowser.chromium),
condition: s.is.bad('chrome'),
format: ['txt', '300x250', '728x90'],
link: { xx: 'https://www.mozilla.org/firefox/' },
text: {
en: ['Drop Google Chrome', 'Surf 2x faster with Firefox Quantum'],
fr: ['Laisser tomber Google Chrome', 'Surfez 2x plus vite avec Firefox Quantum'],
fr: ['Laissez tomber Google Chrome', 'Surfez 2x plus vite avec Firefox Quantum'],
},
tags: ['browser', 'firefox', 'mozilla'],
tags: ['browser', 'firefox', 'mozilla', 'google', 'chrome'],
},
chrome2: {
condition: s.is.bad('chrome'),
format: ['txt', '300x250', '728x90'],
link: { xx: 'https://www.mozilla.org/firefox/' },
text: {
en: ['Chrome is unsecure', 'Firefox protects your data'],
fr: ['Chrome n’est pas sûr', 'Firefox protège vos données'],
},
tags: ['browser', 'firefox', 'mozilla', 'google', 'chrome'],
},
edge: {
condition: (bowser.msedge || bowser.msie),
format: ['txt', '300x250', '728x90'],
link: { xx: 'https://www.mozilla.org/firefox/' },
text: {
en: ['Your browser is unsecure', 'Firefox protects your data'],
fr: ['Votre navigateur n’est pas sûr', 'Firefox protège vos données'],
},
tags: ['browser', 'firefox', 'mozilla', 'microsoft', 'gafam'],
},
firefox: {
condition: (bowser.firefox && bowser.version <= 56),
......@@ -159,6 +176,26 @@
},
tags: ['browser', 'firefox', 'mozilla', 'chrome', 'google'],
},
firefox2: {
condition: s.is.bad('browser'),
format: ['txt', '300x250', '728x90'],
link: { xx: 'https://www.mozilla.org/firefox/' },
text: {
en: ['Firefox Quantum', 'Internet for people, not profit.'],
fr: ['Passez à Firefox Quantum', 'La dernière version ultra-rapide de Mozilla'],
},
tags: ['browser', 'firefox', 'mozilla', 'chrome', 'google'],
},
firefox3: {
condition: s.is.bad('browser'),
format: ['txt', '300x250', '728x90'],
link: { xx: 'https://www.mozilla.org/firefox/' },
text: {
en: ['Firefox Quantum', 'Internet for people, not profit.'],
fr: ['Passez à Firefox Quantum', 'La dernière version ultra-rapide de Mozilla'],
},
tags: ['browser', 'firefox', 'mozilla', 'chrome', 'google'],
},
// Adblock
ublock: {
condition: !s.is.adblock(),
......@@ -171,18 +208,18 @@
tags: ['browser', 'adblock', 'advertising'],
},
green: {
condition: (!s.is.adblock() && (s.is.referrer('lilo.org') || s.is.referrer('ecosia.org'))),
condition: (!s.is.adblock() && (s.is.ref('lilo.org') || s.is.ref('ecosia.org'))),
format: ['txt', '300x250', '728x90'],
link: { xx: 'https://github.com/gorhill/uBlock' },
text: {
en: ['', ''],
fr: ['Un geste écolo et simple', 'Bloquer la pub réduit le trafic web de ~60%'],
en: ['Ecological and easy', 'Blocking advertising reduces web traffic by ~60%'],
fr: ['Écolo et simple', 'Bloquer la pub réduit le trafic web de ~60%'],
},
tags: ['browser', 'adblock', 'advertising', 'green', 'referrer'],
},
// OS
elementary: {
condition: (bowser.windows || bowser.mac),
condition: s.is.bad('pc'),
format: ['txt', '300x250', '728x90'],
link: { xx: 'https://elementary.io' },
text: {
......@@ -192,7 +229,7 @@
tags: ['system', 'elementary', 'windows', 'linux', 'mac'],
},
mageia: {
condition: (bowser.windows || bowser.mac),
condition: s.is.bad('pc'),
format: ['txt', '300x250', '728x90'],
link: { xx: 'https://www.mageia.org' },
text: {
......@@ -202,7 +239,7 @@
tags: ['system', 'mageia', 'windows', 'linux', 'mac'],
},
windows10: {
condition: (bowser.windows && bowser.check({ windows: '10' })),
condition: s.is.bad('win10'),
format: ['txt', '300x250', '728x90'],
link: {
en: 'https://www.ubuntu.com/desktop',
......@@ -684,7 +721,7 @@
return false;
},
referrer(url) {
ref(url) {
const params = window.location.hash.replace(/#/, '').split(';');
return (params[(params.length - 1)] === url);
},
......@@ -721,6 +758,74 @@
return false;
},
// Shortcuts for conditions
bad(target) {
let b = false;
switch (target) {
// Browsers
case 'browser':
b = s.is.bad('chrome') || bowser.safari ||
bowser.opera || bowser.msie || bowser.msedge;
break;
case 'chrome':
b = bowser.chrome || bowser.chromium;
break;
// OS
case 'os':
b = s.is.bad('pc') || s.is.bad('mobile');
break;
case 'pc':
b = bowser.mac || bowser.windows;
break;
case 'mobile':
b = bowser.ios;
break;
case 'win10':
b = bowser.windows && bowser.check({ windows: '10' });
break;
// Referers
case 'search':
b = s.is.ref('google.com') || s.is.ref('bing.com') ||
s.is.ref('yahoo.com');
break;
case 'social':
b = s.is.bad('facebook') || s.is.bad('twitter');
break;
// GAFAM
case 'gafam':
b = s.is.bad('google') || s.is.bad('apple') || s.is.bad('facebook') ||
s.is.bad('amazon') || s.is.bad('microsoft');
break;
case 'google':
b = s.is.bad('chrome') || s.is.ref('google.com')
|| s.is.ref('gmail.com') || s.is.bad('youtube');
break;
case 'apple':
b = bowser.ios || bowser.safari;
break;
case 'facebook':
b = s.is.ref('facebook.com'); // TODO add facebook link reducer
break;
case 'amazon':
b = s.is.ref('amazon.com');
break;
case 'microsoft':
b = bowser.windows || bowser.msie || bowser.msedge ||
s.is.ref('bing.com');
break;
case 'twitter':
b = s.is.ref('twitter.com') || s.is.ref('t.co');
break;
case 'youtube':
b = s.is.ref('youtube.com') || s.is.ref('youtu.be');
break;
default:
// no default
break;
}
return b;
},
},
};
s.init();
......
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