Skip to content
This repository has been archived by the owner on Jul 29, 2024. It is now read-only.

Commit

Permalink
Replacing inline references with file references #101
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanmayer committed Jun 5, 2021
1 parent 675bbbb commit 9699c65
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 32 deletions.
5 changes: 2 additions & 3 deletions src/linkExposure.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ import * as linkResolution from "./linkResolution.js";
import * as matching from "./matching.js";
import * as messaging from "./messaging.js";
import * as pageManager from "./pageManager.js";
import * as inline from "./inline.js";
import * as permissions from "./permissions.js";
import linkExposureContentScript from "./content-scripts/linkExposure.content.js";
import linkExposureContentScript from "include:./content-scripts/linkExposure.content.js";

/**
* Ignore links where the link URL PS+1 is identical to the page URL PS+1.
Expand Down Expand Up @@ -194,7 +193,7 @@ async function addUpdateListener(listener, { linkMatchPatterns, pageMatchPattern
const contentScript = await browser.contentScripts.register({
matches: pageMatchPatterns,
js: [{
code: inline.dataUrlToString(linkExposureContentScript)
file: linkExposureContentScript
}],
runAt: "document_idle"
});
Expand Down
9 changes: 4 additions & 5 deletions src/linkResolution.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@ import * as matching from "./matching.js";
import * as permissions from "./permissions.js";
import * as id from "./id.js";
import * as pageManager from "./pageManager.js";
import * as inline from "./inline.js";
import * as messaging from "./messaging.js";
import { urlShortenerMatchPatterns } from "./data/urlShorteners.js";
import { ampCacheDomains, ampViewerDomainsAndPaths } from "./data/ampCachesAndViewers.js";
import { parse as tldtsParse } from "tldts";
import linkResolutionTwitterContentScript from "./content-scripts/linkResolution.twitter.content.js";
import linkResolutionGoogleNewsContentScript from "./content-scripts/linkResolution.googleNews.content.js";
import linkResolutionTwitterContentScript from "include:./content-scripts/linkResolution.twitter.content.js";
import linkResolutionGoogleNewsContentScript from "include:./content-scripts/linkResolution.googleNews.content.js";

// AMP caches and viewers

Expand Down Expand Up @@ -528,7 +527,7 @@ export function initialize() {
browser.contentScripts.register({
matches: [ "*://*.twitter.com/*" ],
js: [{
code: inline.dataUrlToString(linkResolutionTwitterContentScript)
file: linkResolutionTwitterContentScript
}],
runAt: "document_idle"
});
Expand All @@ -542,7 +541,7 @@ export function initialize() {
browser.contentScripts.register({
matches: [ "*://*.news.google.com/*" ],
js: [{
code: inline.dataUrlToString(linkResolutionGoogleNewsContentScript)
file: linkResolutionGoogleNewsContentScript
}],
runAt: "document_idle"
});
Expand Down
5 changes: 2 additions & 3 deletions src/pageManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,9 @@
import * as events from "./events.js";
import * as idle from "./idle.js";
import * as messaging from "./messaging.js";
import * as inline from "./inline.js";
import * as permissions from "./permissions.js";
import * as timing from "./timing.js";
import pageManagerContentScript from "./content-scripts/pageManager.content.js";
import pageManagerContentScript from "include:./content-scripts/pageManager.content.js";

/**
* The threshold (in seconds) for determining whether the browser has the user's attention,
Expand Down Expand Up @@ -711,7 +710,7 @@ export async function initialize() {
browser.contentScripts.register({
matches: permissions.getManifestOriginMatchPatterns(),
js: [{
code: inline.dataUrlToString(pageManagerContentScript)
file: pageManagerContentScript
}],
runAt: "document_start"
});
Expand Down
5 changes: 2 additions & 3 deletions src/pageNavigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
import * as events from "./events.js";
import * as messaging from "./messaging.js";
import * as pageManager from "./pageManager.js";
import * as inline from "./inline.js";
import * as matching from "./matching.js";
import pageNavigationContentScript from "./content-scripts/pageNavigation.content.js";
import pageNavigationContentScript from "include:./content-scripts/pageNavigation.content.js";

/**
* A listener for the `onPageData` event.
Expand Down Expand Up @@ -152,7 +151,7 @@ async function addListener(listener, {
const contentScript = await browser.contentScripts.register({
matches: matchPatterns,
js: [{
code: inline.dataUrlToString(pageNavigationContentScript)
file: pageNavigationContentScript
}],
runAt: "document_start"
});
Expand Down
5 changes: 2 additions & 3 deletions src/pageText.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,9 @@
import * as messaging from "./messaging.js";
import * as matching from "./matching.js";
import * as events from "./events.js";
import * as inline from "./inline.js";
import * as pageManager from "./pageManager.js";
import * as permissions from "./permissions.js";
import pageTextContentScript from "./content-scripts/pageText.content.js";
import pageTextContentScript from "include:./content-scripts/pageText.content.js";

/**
* A listener for the `onTextParsed` event.
Expand Down Expand Up @@ -215,7 +214,7 @@ async function addListener(listener, {
const contentScript = await browser.contentScripts.register({
matches: matchPatterns,
js: [{
code: inline.dataUrlToString(pageTextContentScript)
file: pageTextContentScript
}],
runAt: "document_idle"
});
Expand Down
9 changes: 4 additions & 5 deletions src/pageTransition.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,10 @@ import * as events from "./events.js";
import * as permissions from "./permissions.js";
import * as messaging from "./messaging.js";
import * as matching from "./matching.js";
import * as inline from "./inline.js";
import * as timing from "./timing.js";
import * as pageManager from "./pageManager.js";
import pageTransitionEventContentScript from "./content-scripts/pageTransition.event.content.js";
import pageTransitionClickContentScript from "./content-scripts/pageTransition.click.content.js";
import pageTransitionEventContentScript from "include:./content-scripts/pageTransition.event.content.js";
import pageTransitionClickContentScript from "include:./content-scripts/pageTransition.click.content.js";

/**
* A listener for the `onPageTransitionData` event.
Expand Down Expand Up @@ -280,7 +279,7 @@ export const onPageTransitionData = events.createEvent({
contentScript: await browser.contentScripts.register({
matches: matchPatterns,
js: [{
code: inline.dataUrlToString(pageTransitionEventContentScript)
file: pageTransitionEventContentScript
}],
runAt: "document_start"
})
Expand Down Expand Up @@ -330,7 +329,7 @@ async function initialize() {
await browser.contentScripts.register({
matches: permissions.getManifestOriginMatchPatterns(),
js: [{
code: inline.dataUrlToString(pageTransitionClickContentScript)
file: pageTransitionClickContentScript
}],
runAt: "document_start"
});
Expand Down
9 changes: 4 additions & 5 deletions src/socialMediaActivity.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@

import * as debugging from "./debugging.js";
import * as messaging from "./messaging.js";
import * as inline from "./inline.js";
import * as permissions from "./permissions.js";
import * as timing from "./timing.js";
import facebookContentScript from "./content-scripts/socialMediaActivity.facebook.content.js";
import twitterContentScript from "./content-scripts/socialMediaActivity.twitter.content.js";
import facebookContentScript from "include:./content-scripts/socialMediaActivity.facebook.content.js";
import twitterContentScript from "include:./content-scripts/socialMediaActivity.twitter.content.js";

permissions.check({
module: "webScience.socialMediaActivity",
Expand Down Expand Up @@ -533,7 +532,7 @@ function tweetContentInit() {
browser.contentScripts.register({
matches: ["https://twitter.com/*", "https://twitter.com/"],
js: [{
code: inline.dataUrlToString(twitterContentScript)
file: twitterContentScript
}],
runAt: "document_idle"
});
Expand Down Expand Up @@ -571,7 +570,7 @@ async function fbPostContentInit() {
await browser.contentScripts.register({
matches: ["https://www.facebook.com/*", "https://www.facebook.com/"],
js: [{
code: inline.dataUrlToString(facebookContentScript)
file: facebookContentScript
}],
runAt: "document_start"
});
Expand Down
9 changes: 4 additions & 5 deletions src/userSurvey.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,9 @@ import * as id from "./id.js";
import * as timing from "./timing.js";
import * as storage from "./storage.js";
import * as messaging from "./messaging.js";
import * as inline from "./inline.js";
import * as permissions from "./permissions.js";
import popupPromptPage from "./html/userSurvey.popupPrompt.html";
import popupNoPromptPage from "./html/userSurvey.popupNoPrompt.html";
import popupPromptPage from "include:./html/userSurvey.popupPrompt.html";
import popupNoPromptPage from "include:./html/userSurvey.popupNoPrompt.html";

/**
* A persistent storage space for data about surveys.
Expand Down Expand Up @@ -165,7 +164,7 @@ async function remindUser() {
*/
function setPopupToNoPromptPage() {
browser.browserAction.setPopup({
popup: inline.dataUrlToBlobUrl(popupNoPromptPage)
popup: browser.runtime.getURL(popupNoPromptPage)
});
}

Expand Down Expand Up @@ -294,7 +293,7 @@ export async function setSurvey(options) {
}
else {
browser.browserAction.setPopup({
popup: inline.dataUrlToBlobUrl(popupPromptPage)
popup: browser.runtime.getURL(popupPromptPage)
});
}

Expand Down

0 comments on commit 9699c65

Please sign in to comment.