-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: embed Overlay as static view in pypi.org (#80)
Close #75 https://user-images.githubusercontent.com/17686879/236821652-c851b860-f269-41a3-a320-3a9475810591.mp4 Waiting for #79 to be merged. --------- Co-authored-by: Jossef Harush Kadouri <[email protected]>
- Loading branch information
Showing
7 changed files
with
65 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import browser from '../browser'; | ||
import { mountContentScript } from './content'; | ||
import { fetchPackageInfo } from './content-events'; | ||
import { urlParsers } from './registry/python'; | ||
|
||
const addPackageReport = (packageID) => { | ||
const packageReport = document.createElement('overlay-package-report'); | ||
packageReport.setAttribute('package-type', packageID.type); | ||
packageReport.setAttribute('package-name', packageID.name); | ||
packageReport.setAttribute('stylesheet-url', browser.runtime.getURL('custom-elements.css')); | ||
|
||
const sidebar = document.querySelector('.vertical-tabs__tabs'); | ||
const sidebarSection = sidebar?.querySelectorAll('.sidebar-section')[1]; | ||
if (!sidebarSection) { | ||
console.log('No side section found (parent of .github-repo-info)'); | ||
return; | ||
} | ||
|
||
sidebar.insertBefore(packageReport, sidebarSection); | ||
}; | ||
|
||
mountContentScript(async () => { | ||
console.log('Running content script for PyPI'); | ||
const packageId = urlParsers[location.hostname.replace('www.', '')]?.(location); | ||
if (!packageId) { | ||
console.log('No package found', packageId); | ||
return; | ||
} | ||
|
||
addPackageReport(packageId); | ||
fetchPackageInfo(packageId); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters