ソースを参照

clean up links

tags/v1.0.5
Jonathan Cobb 4年前
コミット
7e6f047728
1個のファイルの変更31行の追加0行の削除
  1. +31
    -0
      bubble-server/src/main/resources/bubble/rule/social/block/site/FB.js.hbs

+ 31
- 0
bubble-server/src/main/resources/bubble/rule/social/block/site/FB.js.hbs ファイルの表示

@@ -206,6 +206,19 @@ function {{JS_PREFIX}}_should_block(blocked_users, article) {
return false;
}

function {{JS_PREFIX}}_remove_param(href, param) {
const cid = href.indexOf(param+'=');
if (cid !== -1) {
const regex = new RegExp('&?'+param+'=[^?&]+', 'g');
href = href.replace(regex, '');
const qPos = href.indexOf('?');
if (href[qPos+1] === '&') {
href = href.substring(0, qPos) + href.substring(qPos+2);
}
}
return href;
}

function {{JS_PREFIX}}_apply_blocks(blocked_users) {

const mobile = {{JS_PREFIX}}_mobile;
@@ -223,5 +236,23 @@ function {{JS_PREFIX}}_apply_blocks(blocked_users) {
if (authorName) {
{{JS_PREFIX}}_remove_article(article, authorName === true ? null : authorName);
}
Array.from(article.getElementsByTagName('a')).forEach(a => {
let href = a.href;
if (href.indexOf('facebook.com') !== -1 && href.indexOf('u=http') !== -1) {
const uPos = href.indexOf('u=http');
const andPos = href.indexOf('&');
if (andPos !== -1) {
href = href.substring(uPos + 2, andPos);
} else {
href = href.substring(uPos + 2);
}
href = decodeURIComponent(href);
}
href = {{JS_PREFIX}}_remove_param(href, 'fbclid');
href = {{JS_PREFIX}}_remove_param(href, '_ft_');
href = {{JS_PREFIX}}_remove_param(href, '__tn__');
href = {{JS_PREFIX}}_remove_param(href, 'refid');
a.href = href;
});
}
}

読み込み中…
キャンセル
保存