diff --git a/bubble-server/src/main/resources/bubble/rule/RequestModifierRule_icon.js.hbs b/bubble-server/src/main/resources/bubble/rule/RequestModifierRule_icon.js.hbs index 318113bd..c57aeb45 100644 --- a/bubble-server/src/main/resources/bubble/rule/RequestModifierRule_icon.js.hbs +++ b/bubble-server/src/main/resources/bubble/rule/RequestModifierRule_icon.js.hbs @@ -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') { } } }); -} \ No newline at end of file +} + +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); + }); +} diff --git a/bubble-server/src/main/resources/bubble/rule/social/block/JsUserBlockerRuleDriver.js.hbs b/bubble-server/src/main/resources/bubble/rule/social/block/JsUserBlockerRuleDriver.js.hbs index 64b6ecf0..be698074 100644 --- a/bubble-server/src/main/resources/bubble/rule/social/block/JsUserBlockerRuleDriver.js.hbs +++ b/bubble-server/src/main/resources/bubble/rule/social/block/JsUserBlockerRuleDriver.js.hbs @@ -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; diff --git a/bubble-server/src/main/resources/bubble/rule/social/block/site/FB.js.hbs b/bubble-server/src/main/resources/bubble/rule/social/block/site/FB.js.hbs index 2f5ef083..ed46e5d6 100644 --- a/bubble-server/src/main/resources/bubble/rule/social/block/site/FB.js.hbs +++ b/bubble-server/src/main/resources/bubble/rule/social/block/site/FB.js.hbs @@ -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; } diff --git a/utils/cobbzilla-utils b/utils/cobbzilla-utils index 08d7330b..bd7400c5 160000 --- a/utils/cobbzilla-utils +++ b/utils/cobbzilla-utils @@ -1 +1 @@ -Subproject commit 08d7330b5e490b9c89a3cf26930180d9a0d32c0d +Subproject commit bd7400c5b5a0e9ffa88f810c035ad68fee49d733