Skip to content

Commit 919a60d

Browse files
author
Serhiy Barhamon
authored
Merge pull request #7 from Lurk/mothers_day
Mothers day
2 parents 2ae9600 + 0e2e980 commit 919a60d

File tree

5 files changed

+143
-41
lines changed

5 files changed

+143
-41
lines changed

Cargo.lock

Lines changed: 44 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "clink"
3-
version = "0.4.0"
3+
version = "0.4.1"
44
authors = ["Sergey Bargamon <sergey@bargamon.ru>"]
55
edition = "2018"
66

@@ -13,4 +13,5 @@ url = "2.2.0"
1313
rustop = "1.1.1"
1414
rand = "0.8.3"
1515
confy="0.4.0"
16-
serde = { version = "1.0", features = ["derive"] }
16+
serde = { version = "1.0", features = ["derive"] }
17+
chrono = "0.4"

readme.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@ In 0.4.0, we introduced the toml config. Clink will create a "clink.toml" file i
1111
# You can find detail description of modes bellow
1212
# one of: remove, your_mom, evil
1313
mode = 'remove'
14-
# text for your_mom mode
14+
# Text for your_mom mode
1515
your_mom = 'your_mom'
16+
# If true in your_mom mode, Clink will automatically switch to the remove mode in Mother's Day.
17+
except_mothers_day: true,
1618
# How often Clink will check clipboard in milliseconds
1719
sleep_duration = 150
18-
# which GET params Clink should update
20+
# Which GET params Clink should update
1921
params = [
2022
'fbclid', # Facebook click identifier
2123
'gclid', # Google click identifier
@@ -33,8 +35,8 @@ params = [
3335
## Modes
3436

3537
* remove - removes params from links in clipboard
36-
* your_mom - Sets values of params to "your_mom" in links that are in clipboard inspired by this [tweet](https://twitter.com/ftrain/status/1359138516681314311?s=21)
37-
* evil - swap two random chars in values params in links that are in clipboard (Diabolical Laughter)
38+
* your_mom - Sets values to "your_mom" (inspired by this [tweet](https://twitter.com/ftrain/status/1359138516681314311?s=21))
39+
* evil - swap two random chars in values (Diabolical Laughter)
3840

3941
## Build
4042

src/main.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ mod params;
33
mod utils;
44

55
use mode::Mode;
6-
use params::get_default_params;
6+
use params::{create_index, get_default_params};
77
use utils::find_and_replace;
88

99
use clipboard::{ClipboardContext, ClipboardProvider};
@@ -16,6 +16,7 @@ use std::time::Duration;
1616
pub struct ClinkConfig {
1717
mode: Mode,
1818
your_mom: String,
19+
except_mothers_day: bool,
1920
sleep_duration: u64,
2021
params: Vec<String>,
2122
}
@@ -25,8 +26,9 @@ impl ::std::default::Default for ClinkConfig {
2526
Self {
2627
mode: Mode::Remove,
2728
your_mom: "your_mom".to_string(),
28-
params: get_default_params(),
29+
except_mothers_day: true,
2930
sleep_duration: 150,
31+
params: get_default_params(),
3032
}
3133
}
3234
}
@@ -58,12 +60,12 @@ fn main() -> Result<(), confy::ConfyError> {
5860

5961
let mut ctx: ClipboardContext = ClipboardProvider::new().unwrap();
6062
let mut previous_clipboard = "".to_string();
61-
63+
let index = create_index(&cfg.params);
6264
loop {
6365
match ctx.get_contents() {
6466
Ok(current_clipboard) => {
6567
if previous_clipboard != current_clipboard {
66-
let cleaned = find_and_replace(&current_clipboard, &cfg);
68+
let cleaned = find_and_replace(&current_clipboard, &cfg, &index);
6769
if cleaned != current_clipboard {
6870
ctx.set_contents(cleaned.clone()).unwrap();
6971
}

0 commit comments

Comments
 (0)