Skip to content

Commit

Permalink
Adapted to work with Brave Browser
Browse files Browse the repository at this point in the history
  • Loading branch information
arbal committed Feb 6, 2021
1 parent 7938edc commit c26f631
Show file tree
Hide file tree
Showing 12 changed files with 37 additions and 38 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
alfred-chrome-history
chrome-history
alfred-brave-history
brave-history
*.alfredworkflow
build/
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
PROJECT = alfred-chrome-history
PROJECT = alfred-brave-history
TESTARGS ?= -v -race -cover

.PHONY: dist
Expand Down
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
# alfred-chrome-history
# alfred-brave-history

Search Chrome history from Alfred and open in browser.
Search Brave history from Alfred and open in browser.

## Features

- Search Chrome history (title and URL)
- Support another Chrome profile
- Search Brave history (title and URL)
- Support another Brave profile

## Installation

Clone and `make dist` or just download [binary releases](https://github.com/pasela/alfred-chrome-history/releases).
Clone and `make dist` or just download [binary releases](https://github.com/pasela/alfred-brave-history/releases).

```sh
git clone https://github.com/pasela/alfred-chrome-history.git
cd alfred-chrome-history
git clone https://github.com/pasela/alfred-brave-history.git
cd alfred-brave-history
make dist
open alfred-chrome-history.alfredworkflow
open alfred-brave-history.alfredworkflow
```

## Usage
Expand All @@ -26,11 +26,11 @@ in Alfred:
ch {query}
```

## Use another Chrome profile
## Use another Brave profile

1. Open workflow `Chrome History` in Alfred Workflows tab.
1. Open workflow `Brave History` in Alfred Workflows tab.
2. Open Workflow Configuration dialog by upper right side button.
3. Set `CHROME_PROFILE` variable with your Chrome profile directory name or path such as `Profile 1`.
3. Set `CHROME_PROFILE` variable with your Brave profile directory name or path such as `Profile 1`.

## License

Expand Down
Binary file modified _workflow/50B0CD10-4D52-4898-9C05-DD3A34A829C3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified _workflow/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 9 additions & 9 deletions _workflow/info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<plist version="1.0">
<dict>
<key>bundleid</key>
<string>com.github.pasela.alfred-chrome-history</string>
<string>com.github.pasela.alfred-brave-history</string>
<key>category</key>
<string>Internet</string>
<key>connections</key>
Expand Down Expand Up @@ -35,11 +35,11 @@
<key>createdby</key>
<string>pasela</string>
<key>description</key>
<string>Search Chrome history</string>
<string>Search Brave history</string>
<key>disabled</key>
<false/>
<key>name</key>
<string>Chrome History</string>
<string>Brave History</string>
<key>objects</key>
<array>
<dict>
Expand Down Expand Up @@ -68,15 +68,15 @@
<key>runningsubtext</key>
<string></string>
<key>script</key>
<string>./alfred-chrome-history "$@"</string>
<string>./alfred-brave-history "$@"</string>
<key>scriptargtype</key>
<integer>1</integer>
<key>scriptfile</key>
<string>test.sh</string>
<key>subtext</key>
<string>Open Chrome History</string>
<string>Open Brave History</string>
<key>title</key>
<string>Chrome History</string>
<string>Brave History</string>
<key>type</key>
<integer>0</integer>
<key>withspace</key>
Expand Down Expand Up @@ -127,9 +127,9 @@
</dict>
</array>
<key>readme</key>
<string># Chrome History
<string># Brave History
Search Chrome history and open/copy URLs.
Search Brave history and open/copy URLs.
## Configuration
Expand Down Expand Up @@ -167,6 +167,6 @@ You can specify the profile and result limits.
<key>version</key>
<string>1.0</string>
<key>webaddress</key>
<string>https://github.com/pasela/alfred-chrome-history</string>
<string>https://github.com/pasela/alfred-brave-history</string>
</dict>
</plist>
2 changes: 1 addition & 1 deletion alfred.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
)

type WorkflowOptions struct {
Profile string `env:"CHROME_PROFILE"`
Profile string `env:"BRAVE_PROFILE"`
Limit int `env:"LIMIT"`
}

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/pasela/alfred-chrome-history
module github.com/pasela/alfred-brave-history

go 1.13

Expand Down
8 changes: 4 additions & 4 deletions history/history.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"time"

_ "github.com/mattn/go-sqlite3"
"github.com/pasela/alfred-chrome-history/profile"
"github.com/pasela/alfred-chrome-history/utils"
"github.com/pasela/alfred-brave-history/profile"
"github.com/pasela/alfred-brave-history/utils"
"golang.org/x/text/unicode/norm"
)

Expand Down Expand Up @@ -134,12 +134,12 @@ func scanEntry(rows *sql.Rows, entry *Entry) error {
if err != nil {
return err
}
entry.LastVisitTime = convertChromeTime(visit)
entry.LastVisitTime = convertBraveTime(visit)
return nil
}

// https://code.google.com/p/chromium/codesearch#chromium/src/base/time/time.h
func convertChromeTime(msec int64) time.Time {
func convertBraveTime(msec int64) time.Time {
sec := msec / 1000000
nsec := (msec % 1000000) * 1000

Expand Down
6 changes: 3 additions & 3 deletions profile/profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import (
"path/filepath"
"strings"

"github.com/pasela/alfred-chrome-history/utils"
"github.com/pasela/alfred-brave-history/utils"
)

const (
chromeConfigPath = "~/Library/Application Support/Google/Chrome"
braveConfigPath = "~/Library/Application Support/BraveSoftware/Brave-Browser"
)

func GetProfilePath(profile string) (string, error) {
Expand All @@ -19,7 +19,7 @@ func GetProfilePath(profile string) (string, error) {
if profile == "" {
profile = "Default"
}
path = filepath.Join(chromeConfigPath, profile)
path = filepath.Join(braveConfigPath, profile)
}

return utils.ExpandTilde(path)
Expand Down
6 changes: 3 additions & 3 deletions query.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"os"
"path/filepath"

"github.com/pasela/alfred-chrome-history/history"
"github.com/pasela/alfred-chrome-history/utils"
"github.com/pasela/alfred-brave-history/history"
"github.com/pasela/alfred-brave-history/utils"
)

func queryHistory(profile, url, title string, limit int) ([]history.Entry, error) {
Expand Down Expand Up @@ -43,7 +43,7 @@ func (h *historyFile) initTempDir() error {
return nil
}

tempDir, err := ioutil.TempDir("", "alfred-chrome-history")
tempDir, err := ioutil.TempDir("", "alfred-brave-history")
if err != nil {
return err
}
Expand Down
5 changes: 2 additions & 3 deletions standalone.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@ package main
import (
"flag"
"fmt"
"os"
"strings"
)

func run() error {
var limit int
profile := os.Getenv("CHROME_PROFILE")
flag.StringVar(&profile, "profile", profile, "Chrome profile directory")
profile := "Default"
flag.StringVar(&profile, "profile", profile, "Brave profile directory")
flag.IntVar(&limit, "limit", 0, "Limit n results")
flag.Parse()

Expand Down

0 comments on commit c26f631

Please sign in to comment.