|
@@ -10,16 +10,19 @@ import Browser.WebExt.Tabs (Tab)
|
|
|
import Data.Argonaut.Decode (printJsonDecodeError)
|
|
import Data.Argonaut.Decode (printJsonDecodeError)
|
|
|
import Data.Either (Either(..))
|
|
import Data.Either (Either(..))
|
|
|
import Data.Foldable (for_)
|
|
import Data.Foldable (for_)
|
|
|
|
|
+import Data.Int64 as I64
|
|
|
import Data.Maybe (Maybe(..))
|
|
import Data.Maybe (Maybe(..))
|
|
|
import Effect (Effect)
|
|
import Effect (Effect)
|
|
|
import Effect.Aff (launchAff_)
|
|
import Effect.Aff (launchAff_)
|
|
|
import Effect.Class (liftEffect)
|
|
import Effect.Class (liftEffect)
|
|
|
import Effect.Class.Console (debug, error, log, logShow)
|
|
import Effect.Class.Console (debug, error, log, logShow)
|
|
|
-import ExampleWebExt.NativeMessage (NativeMessage(..), connectToNativeApplication, onNativeDisconnectAddListener, onNativeMessageAddListener, sendMessageToNative)
|
|
|
|
|
|
|
+import ExampleWebExt.NativeMessage (ApplicationProcess(..), NativeMessage(..), connectToNativeApplication, onNativeDisconnectAddListener, onNativeMessageAddListener, sendMessageToNative)
|
|
|
import ExampleWebExt.RuntimeMessage (RuntimeMessage(..), onRuntimeMessageAddListener, sendMessageToContent)
|
|
import ExampleWebExt.RuntimeMessage (RuntimeMessage(..), onRuntimeMessageAddListener, sendMessageToContent)
|
|
|
import ExampleWebExt.Storage (clearAllJobs, getJobsPath, storeJob)
|
|
import ExampleWebExt.Storage (clearAllJobs, getJobsPath, storeJob)
|
|
|
import LinkedIn.Jobs.JobOffer (JobOffer(..))
|
|
import LinkedIn.Jobs.JobOffer (JobOffer(..))
|
|
|
import LinkedIn.Output.Types (Output(..))
|
|
import LinkedIn.Output.Types (Output(..))
|
|
|
|
|
+import LinkedIn.PageUrl (PageUrl(..))
|
|
|
|
|
+import LinkedIn.UI.Basic.Types (JobOfferId(..))
|
|
|
import Web.URL as URL
|
|
import Web.URL as URL
|
|
|
|
|
|
|
|
main :: Effect Unit
|
|
main :: Effect Unit
|
|
@@ -43,7 +46,7 @@ browserActionOnClickedHandler tab = do
|
|
|
contentScriptMessageHandler ∷ Port -> RuntimeMessage -> MessageSender → Effect Unit
|
|
contentScriptMessageHandler ∷ Port -> RuntimeMessage -> MessageSender → Effect Unit
|
|
|
contentScriptMessageHandler
|
|
contentScriptMessageHandler
|
|
|
port
|
|
port
|
|
|
- (RuntimeMessagePageContent _ (OutJobOffer offer))
|
|
|
|
|
|
|
+ (RuntimeMessagePageContent (UrlJobOffer (JobOfferId jobId)) (OutJobOffer offer))
|
|
|
(MessageSender {tab: Just {url, title}}) =
|
|
(MessageSender {tab: Just {url, title}}) =
|
|
|
case maybeMsg offer of
|
|
case maybeMsg offer of
|
|
|
Just msg -> sendMessageToNative port msg
|
|
Just msg -> sendMessageToNative port msg
|
|
@@ -51,19 +54,21 @@ contentScriptMessageHandler
|
|
|
|
|
|
|
|
where
|
|
where
|
|
|
maybeMsg (JobOffer jo) = ado
|
|
maybeMsg (JobOffer jo) = ado
|
|
|
- location <- jo.location
|
|
|
|
|
url <- cleanUpUrl url
|
|
url <- cleanUpUrl url
|
|
|
- in NativeMessageVisitedJobPage {
|
|
|
|
|
- url: url,
|
|
|
|
|
- jobTitle: jo.title,
|
|
|
|
|
- pageTitle: title,
|
|
|
|
|
- company: jo.companyName,
|
|
|
|
|
- companyDomain: jo.companyDomain,
|
|
|
|
|
- companyUrl: jo.companyLink,
|
|
|
|
|
- location,
|
|
|
|
|
- hasSimplifiedProcess: jo.hasSimplifiedApplicationProcess,
|
|
|
|
|
- flexibility: jo.flexibility
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ in NativeMessageAddJob {
|
|
|
|
|
+ id: I64.toString jobId,
|
|
|
|
|
+ title: jo.title,
|
|
|
|
|
+ url,
|
|
|
|
|
+ company: jo.companyName,
|
|
|
|
|
+ location: jo.location,
|
|
|
|
|
+ company_domain: jo.companyDomain,
|
|
|
|
|
+ company_url: Just jo.companyLink,
|
|
|
|
|
+ flexibility: jo.flexibility,
|
|
|
|
|
+ application_process: Just $ if jo.hasSimplifiedApplicationProcess then ApplicationProcessLinkedInSimplified else ApplicationProcessRegular,
|
|
|
|
|
+ application_date: Nothing,
|
|
|
|
|
+ application_rejection_date: Nothing,
|
|
|
|
|
+ application_considered: Nothing
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
contentScriptMessageHandler _ m (MessageSender {tab, id}) = do
|
|
contentScriptMessageHandler _ m (MessageSender {tab, id}) = do
|
|
|
let
|
|
let
|