Ver código fonte

minimize url chasing

tags/v1.0.7
Jonathan Cobb 4 anos atrás
pai
commit
eab74db03e
4 arquivos alterados com 40 adições e 32 exclusões
  1. +38
    -29
      bubble-server/src/main/resources/bubble/rule/RequestModifierRule_icon.js.hbs
  2. +0
    -1
      bubble-server/src/main/resources/bubble/rule/social/block/JsUserBlockerRuleDriver.js.hbs
  3. +1
    -1
      bubble-server/src/main/resources/bubble/rule/social/block/site/FB.js.hbs
  4. +1
    -1
      utils/cobbzilla-utils

+ 38
- 29
bubble-server/src/main/resources/bubble/rule/RequestModifierRule_icon.js.hbs Ver arquivo

@@ -88,34 +88,7 @@ function {{JS_PREFIX}}_create_button(labelKey, labelDefault, onclick, labelForma
return btn;
}

function {{JS_PREFIX}}_chase_redirects (a, removeParams) {
if (a.className && a.className.indexOf('{{JS_PREFIX}}_followed') !== -1) return;
if (a.className) {
a.className = a.className + ' {{JS_PREFIX}}_followed';
} else {
a.className = '{{JS_PREFIX}}_followed';
}

a.rel = 'noopener noreferrer nofollow';

fetch('/__bubble/api/filter/follow/{{BUBBLE_REQUEST_ID}}', {method: 'POST', body: JSON.stringify(a.href)})
.then(response => response.text())
.then(data => {
if (data && (data.startsWith('http://') || data.startsWith('https://'))) {
if (typeof removeParams === 'undefined' || removeParams === null || removeParams) {
const qPos = data.indexOf('?');
a.href = qPos === -1 ? data : data.substring(0, qPos);
} else {
a.href = data;
}
} else {
console.warn('chase_redirects: '+a.href+' returned non-URL response: '+data);
}
})
.catch((error) => {
console.error('chase_redirects: error following: '+a.href+': '+error);
});
}
let {{PAGE_PREFIX}}_url_chasers = {};

if (typeof {{PAGE_PREFIX}}_icon_status === 'undefined') {

@@ -258,4 +231,40 @@ if (typeof {{PAGE_PREFIX}}_icon_status === 'undefined') {
}
}
});
}
}

function {{JS_PREFIX}}_chase_redirects (a, removeParams) {
const initial_href = a.href;
if (initial_href in {{PAGE_PREFIX}}_url_chasers) {
a.href = {{PAGE_PREFIX}}_url_chasers[initial_href];
return;
}
if (a.className && a.className.indexOf('{{JS_PREFIX}}_followed') !== -1) return;
if (a.className) {
a.className = a.className + ' {{JS_PREFIX}}_followed';
} else {
a.className = '{{JS_PREFIX}}_followed';
}

a.rel = 'noopener noreferrer nofollow';

fetch('/__bubble/api/filter/follow/{{BUBBLE_REQUEST_ID}}', {method: 'POST', body: JSON.stringify(initial_href)})
.then(response => response.text())
.then(data => {
if (data && (data.startsWith('http://') || data.startsWith('https://'))) {
if (typeof removeParams === 'undefined' || removeParams === null || removeParams) {
const qPos = data.indexOf('?');
a.href = qPos === -1 ? data : data.substring(0, qPos);
} else {
a.href = data;
}
{{PAGE_PREFIX}}_url_chasers[initial_href] = a.href;
console.log('chase_redirect: rewrote '+initial_href+' -> '+a.href);
} else {
console.warn('chase_redirects: '+a.href+' returned non-URL response: '+data);
}
})
.catch((error) => {
console.error('chase_redirects: error following: '+a.href+': '+error);
});
}

+ 0
- 1
bubble-server/src/main/resources/bubble/rule/social/block/JsUserBlockerRuleDriver.js.hbs Ver arquivo

@@ -239,7 +239,6 @@ function {{JS_PREFIX}}_includes_block_keyword (element, firstEval) {
} else {
if (html.toLowerCase().indexOf(kw.toLowerCase()) !== -1) {
// {{PAGE_PREFIX}}_log('>>> includes_block_keyword: blocking based on case-insensitive keyword: ' + kw);
console.log('>>> includes_block_keyword: blocking based on case-insensitive keyword: ' + kw);
if ({{JS_PREFIX}}_mark_removed(element)) {{JS_PREFIX}}_tally_keyword_block(kw);
if (!firstEval) {{JS_PREFIX}}_untally_allow();
return true;


+ 1
- 1
bubble-server/src/main/resources/bubble/rule/social/block/site/FB.js.hbs Ver arquivo

@@ -357,7 +357,7 @@ function {{JS_PREFIX}}_apply_blocks(blocked_users) {
a.removeAttribute('data-gt');
a.removeAttribute('data-sigil');
a.href = href;
{{JS_PREFIX}}_chase_redirects(a);
{{JS_PREFIX}}_chase_redirects(a, false);
} else {
a.href = href;
}


+ 1
- 1
utils/cobbzilla-utils

@@ -1 +1 @@
Subproject commit 08d7330b5e490b9c89a3cf26930180d9a0d32c0d
Subproject commit bd7400c5b5a0e9ffa88f810c035ad68fee49d733

Carregando…
Cancelar
Salvar