diff --git a/public/_locales/en/messages.json b/public/_locales/en/messages.json index df50b436..e7cbfaa0 100644 --- a/public/_locales/en/messages.json +++ b/public/_locales/en/messages.json @@ -1205,5 +1205,8 @@ "actions": { "message": "Actions", "description": "Header of the unsubmitted segments list" + }, + "exportSegmentsAsURL": { + "message": "Export segments as URL" } } diff --git a/src/components/options/UnsubmittedVideoListItem.tsx b/src/components/options/UnsubmittedVideoListItem.tsx index c203f533..d670461d 100644 --- a/src/components/options/UnsubmittedVideoListItem.tsx +++ b/src/components/options/UnsubmittedVideoListItem.tsx @@ -1,7 +1,7 @@ import * as React from "react"; import Config from "../../config"; -import { exportTimes } from "../../utils/exporter"; +import { exportTimes, exportTimesAsHashParam } from "../../utils/exporter"; export interface UnsubmittedVideosListItemProps { videoID: string; @@ -47,6 +47,12 @@ class UnsubmittedVideoListItem extends React.Component {" "} +
+ {chrome.i18n.getMessage("exportSegmentsAsURL")} +
+ {" "}
@@ -68,7 +74,15 @@ class UnsubmittedVideoListItem extends React.Component { alert(chrome.i18n.getMessage("CopiedExclamation")); }) diff --git a/src/utils/exporter.ts b/src/utils/exporter.ts index 089ef782..fe2b4f88 100644 --- a/src/utils/exporter.ts +++ b/src/utils/exporter.ts @@ -73,4 +73,15 @@ export function importTimes(data: string, videoDuration: number): SponsorTime[] } return result; -} \ No newline at end of file +} + +export function exportTimesAsHashParam(segments: SponsorTime[]): string { + const hashparamSegments = segments.map(segment => ({ + actionType: segment.actionType, + category: segment.category, + segment: segment.segment, + ...(segment.description ? {description: segment.description} : {}) // don't include the description param if empty + })); + + return `#segments=${JSON.stringify(hashparamSegments)}`; +}