Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@
* 書き込み権限がない場合、コマンドプロンプトを管理者権限で起動して作成する
* `C:\Program Files\RepostConfirmationCanceler\RepostConfirmationCanceler.ini` のアクセス権を変更し、ユーザー権限での書き込みを許可した上で、以下のような内容を記載する
* ```
[Edge]
[TARGETS]
*
```

## 動作解説

* ブラウザの拡張機能 RepostConfirmationCanceler が、`RepostConfirmationCanceler.ini`の`[Edge]`セクションに記載されているURLを開いているかを判定する
* ブラウザの拡張機能 RepostConfirmationCanceler が、`RepostConfirmationCanceler.ini`の`[TARGETS]`セクションに記載されているURLを開いているかを判定する
* サイトを開いたタイミングと、30秒ごとのポーリングで判定を行う
* 指定のURLを開いていた場合、ブラウザの拡張機能が RepostConfirmationCancelerTalk.exe を呼び出す。
* このとき、`Q Edge`というメッセージを送信する
Expand Down
33 changes: 3 additions & 30 deletions RepostConfirmationCanceler/ConfigLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ namespace RepostConfirmationCanceler
internal class Section
{
public string Name;
public bool Disabled = false;
public bool WarningWhenCloseDialog = false;
public StringBuilder ExcludeGroups = new StringBuilder();
public StringBuilder Excludes = new StringBuilder();
public StringBuilder Patterns = new StringBuilder();

Expand All @@ -27,12 +24,8 @@ internal class Config
{
public bool IgnoreQueryString = false;
public bool OnlyMainFrame = false;
public bool WarningWhenCloseDialog = false;
public List<Section> SectionList = new List<Section>();

public Section GetEdgeSection()
{
return SectionList.FirstOrDefault(_ => _.Name.ToLowerInvariant() == "[edge]");
}
}

internal static class ConfigLoader
Expand Down Expand Up @@ -120,29 +113,9 @@ internal static Config ParseConf(string data)
case '@':
if (global)
{
if (line == "@TOP_PAGE_ONLY")
{
conf.IgnoreQueryString = true;
}
else if (line == "@ONLY_MAIN_FRAME")
{
conf.OnlyMainFrame = true;
}
}
else if (section != null)
{
if (line == "@DISABLED")
{
section.Disabled = true;
}
else if (line == "@WARNING_WHEN_CLOSE_DIALOG")
{
section.WarningWhenCloseDialog = true;
}
else if (line.StartsWith("@EXCLUDE_GROUP:"))
if (line == "@WARNING_WHEN_CLOSE_DIALOG")
{
section.ExcludeGroups.Append(line.Substring("@EXCLUDE_GROUP:".Length));
section.ExcludeGroups.Append('\n');
conf.WarningWhenCloseDialog = true;
}
}
break;
Expand Down
3 changes: 1 addition & 2 deletions RepostConfirmationCanceler/EdgeConfirmationDialogCanceler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,7 @@ internal static void CancelDialog(RuntimeContext context, AutomationElement edge
return;
}

var edgeConfig = context.Config.GetEdgeSection();
if (edgeConfig?.WarningWhenCloseDialog ?? false)
if (context.Config?.WarningWhenCloseDialog ?? false)
{
context.Logger.Log($"Display warning dialog");
ShowWarningDialog();
Expand Down
63 changes: 11 additions & 52 deletions RepostConfirmationCancelerTalk/cb_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,13 @@
*/
struct section {
char name[16];
int disabled;
struct strbuf exclude_groups;
struct strbuf patterns;
struct strbuf excludes;
struct section *next; /* linked list */
};

struct config {
int only_main_frame;
int ignore_query_string;
int warning_when_close_dialog;
struct section *section;
};

Expand Down Expand Up @@ -64,9 +61,9 @@ static struct section *new_section(char *line)
* You can define variables/URLs in each section like this:
*
* [GLOBAL]
* @TOP_PAGE_ONLY
* @WARNING_WHEN_CLOSE_DIALOG
*
* [Edge]
* [TARGETS]
* https://example.com*
* -https://test.example.com*
*
Expand All @@ -77,7 +74,6 @@ static void parse_conf(char *data, struct config *conf)
{
char *line;
int global;
int _default;
struct section *section;
struct section **indirect = &conf->section;

Expand All @@ -89,14 +85,10 @@ static void parse_conf(char *data, struct config *conf)
break;
case '[':
global = 0;
_default = 0;

if (strcmp(line, "[GLOBAL]") == 0) {
global = 1;
}
else if (strcmp(line, "[Default]") == 0) {
_default = 1;
}
else {
section = new_section(line);
*indirect = section;
Expand All @@ -105,20 +97,9 @@ static void parse_conf(char *data, struct config *conf)
break;
case '@':
if (global) {
if (strcmp(line, "@TOP_PAGE_ONLY") == 0) {
conf->ignore_query_string = 1;
}
else if (strcmp(line, "@ONLY_MAIN_FRAME") == 0) {
conf->only_main_frame = 1;
}
}
else if (section) {
if (strcmp(line, "@DISABLED") == 0) {
section->disabled = 1;
}
else if (strstr(line, "@EXCLUDE_GROUP:") == line) {
strbuf_concat(&section->exclude_groups, line + strlen("@EXCLUDE_GROUP:"));
strbuf_putchar(&section->exclude_groups, '\n');
if (line == "@WARNING_WHEN_CLOSE_DIALOG")
{
conf->warning_when_close_dialog = 1;
}
}
break;
Expand Down Expand Up @@ -150,22 +131,6 @@ static char *dump_section(struct section *section)
strbuf_concat_jsonstr(&sb, section->name, strlen(section->name));
strbuf_putchar(&sb, ',');

strbuf_concat(&sb, "\"ExcludeGroups\":[");
if (section->exclude_groups.buf) {
ptr = section->exclude_groups.buf;
need_comma = 0;
while (*ptr) {
if (need_comma)
strbuf_putchar(&sb, ',');

end = strchr(ptr, '\n');
strbuf_concat_jsonstr(&sb, ptr, end - ptr);
need_comma = 1;
ptr = end + 1;
}
}
strbuf_concat(&sb, "],");

/* URLPatterns */
strbuf_concat(&sb, "\"Patterns\":[");
if (section->patterns.buf) {
Expand Down Expand Up @@ -211,14 +176,9 @@ static char *dump_json(struct config *conf)
char *json;
int need_comma;

/* OnlyMainFrame */
strbuf_concat(&sb, "{\"OnlyMainFrame\":");
strbuf_concat(&sb, _itoa(conf->only_main_frame, buf, 10));
strbuf_putchar(&sb, ',');

/* IgnoreQueryString */
strbuf_concat(&sb, "\"IgnoreQueryString\":");
strbuf_concat(&sb, _itoa(conf->ignore_query_string, buf, 10));
/* WarningWhenCloseDialog */
strbuf_concat(&sb, "{\"WarningWhenCloseDialog\":");
strbuf_concat(&sb, _itoa(conf->warning_when_close_dialog, buf, 10));
strbuf_putchar(&sb, ',');

/* Sections */
Expand All @@ -227,8 +187,8 @@ static char *dump_json(struct config *conf)
section = conf->section;
need_comma = 0;
while (section) {
/* Disabled or no pattern defined */
if (section->disabled || section->patterns.buf == NULL) {
/* no pattern defined */
if (section->patterns.buf == NULL) {
section = section->next;
continue;
}
Expand Down Expand Up @@ -336,7 +296,6 @@ int cb_config(char *cmd)
section = conf.section;
while (section) {
next = section->next;
free(section->exclude_groups.buf);
free(section->patterns.buf);
free(section->excludes.buf);
free(section);
Expand Down
2 changes: 1 addition & 1 deletion Resources/RepostConfirmationCanceler.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
## Configuration File for RepostConfirmationCanceler (ver1.0)
#####################################################################

[Edge]
[TARGETS]
*
60 changes: 41 additions & 19 deletions doc/Sources/user-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -355,27 +355,62 @@ RepostConfirmationCancelerセットアップ先のRepostConfirmationCanceler.ini

例) `C:\Program Files\RepostConfirmationCanceler\RepostConfirmationCanceler.ini`

## 設定ファイルの書式

設定ファイルは、以下のように`[GLOBAL]`セクションと`[TARGETS]`セクションに分かれています。

```
[GLOBAL]
@WARNING_WHEN_CLOSE_DIALOG

[TARGETS]
https://example.com/*
-https://example.com/test/
```

各セクションに対して、必要な項目を設定します。

## 設定項目の一覧

Edgeでの動作については、`[Edge]`セクションに記載します。
### 一般設定

一般設定については、`[GLOBAL]`セクションに記載します。

| 項目 | 設定内容 | 既定 |
|------------|---------------------------------------|------|
| 対象URL一覧(書式は後述) | 「フォームを再送信しますか?」ダイアログをキャンセルするURL|*(すべてのURL)|
| @WARNING_WHEN_CLOSE_DIALOG | 「フォームを再送信しますか?」ダイアログをキャンセルしたとき、追加の警告ダイアログを表示する | 無効 |

#### @WARNING_WHEN_CLOSE_DIALOG

フォームを再送信しますか?」ダイアログをキャンセルしたとき、以下のような追加の警告ダイアログを表示します。

![](user-guide/media/image31.png)

以下のように値なしのパラメータとして指定します。

```
[GLOBAL]
@WARNING_WHEN_CLOSE_DIALOG
```

### 対象URL一覧

対象URL一覧については、`[TARGETS]`セクションに記載します。

| 項目 | 設定内容 | 既定 |
|------------|---------------------------------------|------|
| 対象URL一覧(書式は後述) | 「フォームを再送信しますか?」ダイアログをキャンセルするURL|*(すべてのURL)|

注: いずれかのタブで対象URLを開いている場合に本プログラムが動作します。実際に開いているURLが対象URLでなくても、別のタブで対象URLを
開いている場合、「フォームを再送信しますか?」ダイアログがキャンセルされます。

### 対象URL一覧書式
#### 対象URL一覧書式

対象URL一覧は以下のようにURL全体を改行切りで指定します。

例)

```
[Edge]
[TARGETS]
https://www.clear-code.com/
https://example.com/
```
Expand All @@ -402,26 +437,13 @@ https://example.com/
例)

```
[Edge]
[TARGETS]
https://example.com/*
-https://example.com/test/
```

これは「`https://example.com/`を含むサイトを対象とするが、`https://example.com/test/`は除外する」という設定です。

### @WARNING_WHEN_CLOSE_DIALOG

フォームを再送信しますか?」ダイアログをキャンセルしたとき、以下のような追加の警告ダイアログを表示します。

![](user-guide/media/image31.png)

以下のように値なしのパラメータとして指定します。

```
[Edge]
@WARNING_WHEN_CLOSE_DIALOG
```

## グループポリシー(GPO)を利用した設定ファイルの配布手順

ADに所属している端末の設定を強制する場合、グループポリシー(GPO)で設定ファイルを配布することで強制します。
Expand Down
2 changes: 1 addition & 1 deletion doc/verify/sources/TestTools/Senarios/scenario1.ini
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[Edge]
[TARGETS]
*
4 changes: 3 additions & 1 deletion doc/verify/sources/TestTools/Senarios/scenario2.ini
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
[Edge]
[GLOBAL]
@WARNING_WHEN_CLOSE_DIALOG

[TARGETS]
*
2 changes: 1 addition & 1 deletion doc/verify/sources/TestTools/Senarios/scenario3.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[Edge]
[TARGETS]
*://example.com/jp*
*://example.com/us/??/
https://www.clear-code.com/
Expand Down
Loading
Loading