Skip to content

Commit

Permalink
Merge pull request #13 from farblos/10-version-for-chromium-web-browsers
Browse files Browse the repository at this point in the history
Prepared for release of version 2.6
  • Loading branch information
farblos authored Dec 27, 2023
2 parents 4e37824 + a401b23 commit 9f98662
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 10 deletions.
45 changes: 39 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,20 @@ jobs:
steps:

- name: Check Out Sources
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Check Out CRX3-Creator
uses: actions/checkout@v4
with:
repository: ${{ format( '{0}/CRX3-Creator', github.repository_owner ) }}
ref: 'a5d25b6ccc2007be41bd9cc534dfa51a52692780'
path: 'crx3-creator'

- name: Install Additional Software
run: |
# required for CRX3-Creator
sudo apt-get install python3-googleapi
sudo apt-get install python3-protobuf
- name: Determine Some Strings from Tag
run: |
Expand All @@ -35,26 +48,34 @@ jobs:
fi
# determine v-prefixed version, simple version,
# extension version, XPI base name and export them
# extension version, XPI base name, CRX base name and
# export them
vversion=$tagname
sversion=${tagname#v}
[[ $tagname =~ ^v(2\.[0-9]+)(\.[0-9]+)?$ ]]
xversion=${BASH_REMATCH[1]}
xpibname="copy-on-select-2-unsigned-$sversion.xpi"
crxbname="copy-on-select-2-$sversion.crx"
echo "vversion=$vversion" >> $GITHUB_ENV
echo "sversion=$sversion" >> $GITHUB_ENV
echo "xversion=$xversion" >> $GITHUB_ENV
echo "xpibname=$xpibname" >> $GITHUB_ENV
echo "crxbname=$crxbname" >> $GITHUB_ENV
# ensure the new version is maintained in the extension
# manifest
- name: Verify Manifest
run: |
mversion=$( jq -r '.version' src/manifest.json )
if [[ $xversion != $mversion ]]; then
if [[ $xversion != "$mversion" ]]; then
echo "Cannot find version \"$xversion\" in manifest." 1>&2
exit 1
fi
mfversion=$( jq -r '.manifest_version' src/manifest.json )
if [[ $mfversion != 2 ]]; then
echo "Cannot process manifest version $mfversion." 1>&2
exit 1
fi
# ensure the new version is described in the version
# history and use its description as release description
Expand Down Expand Up @@ -97,12 +118,23 @@ jobs:
mkdir -p build
zip -jqr "build/$xpibname" src
- name: Create Release and Upload XPI
- name: Create CRX
env:
CRX_PEM: ${{ secrets.CRX_PEM }}
run: |
mkdir -p build tmp
jq '.manifest_version = 3' src/manifest.json > tmp/manifest.json
mv tmp/manifest.json src/manifest.json
printf '%s\n' "$CRX_PEM" > tmp/crx.pem
python3 crx3-creator/main.py -o "build/$crxbname" \
-pem tmp/crx.pem src
- name: Create Release and Upload Packages
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
draft=""
if [[ $sversion != $xversion ]]; then
if [[ $sversion != "$xversion" ]]; then
draft="--draft"
else
draft=""
Expand All @@ -111,4 +143,5 @@ jobs:
gh release create $draft \
--title "Version $sversion" \
--notes-file tmp/reldesc.md \
"$vversion" "build/$xpibname"
"$vversion" "build/$xpibname" \
"build/$crxbname"
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,42 @@ is

[![Firefox Latest](https://img.shields.io/amo/v/copy-on-select-2)][link-amo]

- Chromium-based browsers (Brave, Ungoogled Chromium)

Download the latest CRX package from the [release
page](https://github.com/farblos/copy-on-select-2/releases) and
drag-and-drop it onto your browser or open it as a file with
`Ctrl+O`.

## Known Issues

Version 2.6

- Option "Copy-on-select in input elements" is not effective on
chromium-based browsers. In the sense that on these you cannot
*disable* copy-on-select in input elements.

The same is true for non-standard input fields on all browsers,
see ["pontoon.mozilla.org" input form problem][issue_12].

[issue_12]: https://github.com/farblos/copy-on-select-2/issues/12

<!--
== Keep GitHub workflow release.yml in sync with the format of
== the section below.
-->

## Version History

Version 2.6

- Implements RFE [Version for chromium web browsers][issue_10].

Polyfills missing APIs. Adds release steps to create an MV3,
CRX3 package (while leaving MV2 for the Firefox XPI).

[issue_10]: https://github.com/farblos/copy-on-select-2/issues/10

Version 2.5

- Fixes issue [Does not work on local web pages in htmlz format][issue_8].
Expand Down
12 changes: 11 additions & 1 deletion src/copy-on-select.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
"use strict";

// polyfill the "browser" global for chromium compatibility
if ( (typeof globalThis.browser === "undefined") &&
(typeof globalThis.chrome !== "undefined") )
globalThis.browser = chrome;

var CopyOnSelect = {

// options
Expand Down Expand Up @@ -48,7 +53,12 @@ var CopyOnSelect = {
else if ( (s.length > 0) )
this.copy( s );

// copy selection on input element
// copy selection on input element. Chromium-based browsers
// do not handle selections in input elements differently
// from regular selections. Accordingly, on these browsers
// we do not reach this branch when text from an input
// element is selected, and user option "in_input_elements"
// is not effective.
else if ( (this.in_input_elements) &&
(t === document.activeElement) &&
(typeof t.value === "string") &&
Expand Down
5 changes: 2 additions & 3 deletions src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "A productivity tool which copies selected text to the clipboard automatically.",
"homepage_url": "https://github.com/farblos/copy-on-select-2",

"version": "2.5",
"version": "2.6",

"icons": {
"128": "copy-on-select-128.png"
Expand All @@ -28,8 +28,7 @@
],

"options_ui": {
"page": "options.html",
"browser_style": true
"page": "options.html"
},

"manifest_version": 2
Expand Down
5 changes: 5 additions & 0 deletions src/options.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
"use strict";

// polyfill the "browser" global for chromium compatibility
if ( (typeof globalThis.browser === "undefined") &&
(typeof globalThis.chrome !== "undefined") )
globalThis.browser = chrome;

async function load()
{
let o = await browser.storage.local.get();
Expand Down

0 comments on commit 9f98662

Please sign in to comment.