Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove normalizeLinksContentScript #836

Merged
merged 1 commit into from
Dec 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion add-on/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@
"description": "An option title on the Preferences screen (option_catchUnhandledProtocols_title)"
},
"option_catchUnhandledProtocols_description": {
"message": "Enables support for ipfs://, ipns:// and dweb: by normalizing links and requests done with unhandled protocols",
"message": "Enables provisional support for ipfs://, ipns:// and dweb: by redirecting unhandled address bar requests to an HTTP gateway",
"description": "An option description on the Preferences screen (option_catchUnhandledProtocols_description)"
},
"option_linkify_title": {
Expand Down
93 changes: 0 additions & 93 deletions add-on/src/contentScripts/normalizeLinksWithUnhandledProtocols.js

This file was deleted.

26 changes: 2 additions & 24 deletions add-on/src/lib/ipfs-companion.js
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ module.exports = async function init () {
if (!details.url.startsWith('http')) return // skip special pages
// console.info(`[ipfs-companion] onDOMContentLoaded`, details)
if (state.linkify) {
console.info(`[ipfs-companion] Running linkfy experiment for ${details.url}`)
log(`running linkfy experiment on ${details.url}`)
try {
await browser.tabs.executeScript(details.tabId, {
file: '/dist/bundles/linkifyContentScript.bundle.js',
Expand All @@ -377,29 +377,7 @@ module.exports = async function init () {
runAt: 'document_idle'
})
} catch (error) {
console.error(`Unable to linkify DOM at '${details.url}' due to`, error)
}
}
if (state.catchUnhandledProtocols) {
// console.log(`[ipfs-companion] Normalizing links with unhandled protocols at ${tab.url}`)
// See: https://github.com/ipfs/ipfs-companion/issues/286
try {
// pass the URL of user-preffered public gateway
await browser.tabs.executeScript(details.tabId, {
code: `window.ipfsCompanionPubGwURL = '${state.pubGwURLString}'`,
matchAboutBlank: false,
allFrames: true,
runAt: 'document_start'
})
// inject script that normalizes `href` and `src` containing unhandled protocols
await browser.tabs.executeScript(details.tabId, {
file: '/dist/bundles/normalizeLinksContentScript.bundle.js',
matchAboutBlank: false,
allFrames: true,
runAt: 'document_end'
})
} catch (error) {
console.error(`Unable to normalize links at '${details.url}' due to`, error)
log.error(`Unable to linkify DOM at '${details.url}' due to`, error)
}
}
if (details.url.startsWith(state.webuiRootUrl)) {
Expand Down
3 changes: 1 addition & 2 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,7 @@ const contentScriptsConfig = merge(commonConfig, {
name: 'contentScripts',
entry: {
ipfsProxyContentScriptPayload: './add-on/src/contentScripts/ipfs-proxy/page.js',
linkifyContentScript: './add-on/src/contentScripts/linkifyDOM.js',
normalizeLinksContentScript: './add-on/src/contentScripts/normalizeLinksWithUnhandledProtocols.js'
linkifyContentScript: './add-on/src/contentScripts/linkifyDOM.js'
}
})

Expand Down