Closed jonathanmayer closed 3 years ago
Migrated to the web-science
repo.
socialMediaLinkSharing.js
: https://github.com/mozilla-rally/web-science/issues/17socialMediaActivity.facebook.content.js
: https://github.com/mozilla-rally/web-science/issues/15socialMediaActivity.twitter.content.js
: https://github.com/mozilla-rally/web-science/issues/15socialMediaActivity.js
: https://github.com/mozilla-rally/web-science/issues/23
Terrific work @akohlbre putting together our social media activity functionality in https://github.com/citp/web-science/commit/cfc64ac4d72fab2fd81e1ebf5d27563158b17106. The pipeline in Utilities/SocialMediaActivity.js is elegant engineering—a bunch of messy HTTP(S) parsing turned into clean and clear abstractions. Suggestions below, the vast majority of which are minor.
Studies/SocialMediaSharing.js
filterTokensToUrls
to be more descriptiveSocialMediaLinkSharing
)Studies/facebook.js
Utilities/content-scripts/
socialMediaActivity-facebook.js
)browser.runtime.onMessage
listenerStudies/twitter.js
socialMediaActivity-twitter.js
)getTweetContent
functionconsole.log
browser.runtime.onMessage
listenerresponse
(a holdover from the Facebook content script?)Utilities/SocialMediaActivity.js
WebScience
import and add aMessaging
importdebugLog
import or remove it if unnecessaryvar
svar
s for consistencyregisterPlatformListener
documentation to clarify what the function does (sets up an internal listener if necessary and saves the client callback) and that the function is internal to the moduleregisterPlatformListener
to match what the function does (e.g.,registerActivityListenerAndStoreCallback
)boolean
rather than astring
for the blocking parameter inregisterPlatformListener
(and associated logic) to avoid repetition in the other listener registration functionshandler.stage
for clarity (e.g.,handler.webRequestStage
)handler.urls
for clarity (e.g.,platformActivityUrls
)await verifier({
...,await extractor({
..., andcompleter({
...Promise
wrapper inhandleGenericEvent
verifyPostReq
for clarity (e.g.,verifyPostRequest
)platformHandlers
andclientCallbacks
to avoid repetitionplatformHandlers.twitter.tweet
) into theplatformHandlers
assignment to avoid repetition; for all the fields that are optional or initialize to null, you can also avoid repetition by iterating over the events oncegetTweetContent
into the module rather than message passing with a content script; unless I'm missing something, none of this logic requires a content script (but it might require setting aReferer
header for a Twitter webpage)tweetContentInit
for claritytweetContentInit
explaining how it handles the scenario where the user hasn't yet logged into Twitter (i.e., it'll grab the relevant values as soon as the user logs in)fbPostContentInit
for claritybrowser.contentScripts.register
filesnull
or setting anull
timeparseFacebookPost
(unsure what's going on there, and looks like it belongs in a content script)requestPostContents
to include Facebookasync
functions rather thanPromise
returns forrequestPostContents
,getFacebookPostContents
, andgetRedditThingContents
(since that's the style we've been generally using in other modules)boolean
for the verification function return values rather thannull
or{ }