diff --git a/app/siteHacks.js b/app/siteHacks.js index ddf5a37636b..ac87240551b 100644 --- a/app/siteHacks.js +++ b/app/siteHacks.js @@ -25,15 +25,22 @@ module.exports.init = () => { let domain = URL.parse(details.url).hostname.split('.').slice(-2).join('.') let hack = siteHacks[domain] let customCookie + let cancel + const firstPartyUrl = Filtering.getMainFrameUrl(details) if (hack && hack.onBeforeSendHeaders) { const result = hack.onBeforeSendHeaders.call(this, details) if (result && result.customCookie) { customCookie = result.customCookie + } else if (Filtering.isResourceEnabled(appConfig.resourceNames.NOSCRIPT, firstPartyUrl) && + result && result.cancel) { + // cancel is only called on Twitter where noscript is enabled + cancel = true } } return { resourceName, - customCookie + customCookie, + cancel } }) Filtering.registerBeforeRequestFilteringCB((details) => { diff --git a/js/data/siteHacks.js b/js/data/siteHacks.js index e3fa2f8f9f9..083db2a630d 100644 --- a/js/data/siteHacks.js +++ b/js/data/siteHacks.js @@ -114,6 +114,17 @@ module.exports.siteHacks = { } } }, + 'twitter.com': { + onBeforeSendHeaders: function(details) { + if (details.requestHeaders.Referer && + details.requestHeaders.Referer.startsWith('https://twitter.com/') && + details.url.startsWith('https://mobile.twitter.com/')) { + return { + cancel: true + } + } + } + }, 'play.spotify.com': { enableFlashCTP: true },