Skip to content
This repository was archived by the owner on Jun 24, 2021. It is now read-only.

Commit d42c039

Browse files
committed
Fixed event misfiring
1 parent fde54cc commit d42c039

File tree

6 files changed

+51
-49
lines changed

6 files changed

+51
-49
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.DS_store

content.js renamed to contents/content.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121
return resolve(element);
2222
});
2323
}, delay);
24-
} else {
25-
alert('twitter-cutomized-muting extension error: Failed to select element: ' + id);
2624
}
2725
});
2826
};
@@ -133,12 +131,12 @@
133131
RetryableGetElementById('stream-items-id', 5, 500).then(function (streamItems) {
134132
PreObserver.observe(streamItems);
135133
MuteObserver.observe(streamItems);
136-
RefreshObserver.observe(document);
137134
});
135+
RefreshObserver.observe(document);
138136

139137
/* Insert mute button */
140138
document.styleSheets[0].insertRule('.Icon--volume-off:before { content: "\\f056"}', 0);
141-
(function (topbar) {
139+
RetryableGetElementById('global-actions', 0, 0).then(function (topbar) {
142140
var icon = document.createElement('span');
143141
icon.className = 'Icon Icon--volume-off Icon--large';
144142
var text = document.createElement('span');
@@ -177,7 +175,7 @@
177175
li.id = 'mute-nav-id';
178176
li.appendChild(a);
179177
topbar.appendChild(li);
180-
})(document.getElementById('global-actions'));
178+
});
181179

182180
};
183181
iframe.setAttribute('src', chrome.extension.getURL('sandbox.html'));

icons/icon128.png

22.1 KB
Loading

manifest.json

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
{
2-
"name": "twitter-customized-muting",
3-
"version": "0.3.0",
2+
"name": "Twitter Customized Muting",
3+
"version": "1.0.0",
44
"manifest_version": 2,
55
"description": "カスタマイズ可能なミュート機能をTwitter公式Web版に提供",
66
"content_scripts": [{
7-
"js": ["content.js"],
7+
"js": ["contents/content.js"],
88
"matches": ["https://twitter.com/*"],
99
"run_at": "document_end"
1010
}],
1111
"sandbox": {
12-
"pages": ["sandbox.html"]
12+
"pages": ["sandboxes/sandbox.html"]
1313
},
14-
"web_accessible_resources": ["sandbox.html"]
14+
"icons": {
15+
"128": "icons/icon128.png"
16+
},
17+
"web_accessible_resources": ["sandboxes/sandbox.html"]
1518
}
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
<!DOCTYPE html>
2-
<html>
3-
<head>
4-
<script src="sandbox.js"></script>
5-
</head>
6-
<body>
7-
</body>
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<script src="sandbox.js"></script>
5+
</head>
6+
<body>
7+
</body>
88
</html>
Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
1-
(function () {
2-
3-
var callback = function () { return false; };
4-
5-
window.addEventListener('message', function (e) {
6-
switch (e.data.actionType) {
7-
case 'set-callback':
8-
callback = new Function(
9-
'user_id_str',
10-
'screen_name',
11-
'name',
12-
'text',
13-
'is_in_notification_area',
14-
'is_promotion',
15-
'is_retweet',
16-
'retweeter_user_id_str',
17-
'retweeter_screen_name',
18-
'retweeter_name',
19-
e.data.code
20-
);
21-
break;
22-
case 'go-callback':
23-
if (callback.apply({}, e.data.params)) {
24-
e.source.postMessage({
25-
actionType: 'tcm-remove-tweet',
26-
itemId: e.data.itemId,
27-
}, e.origin);
28-
}
29-
break;
30-
}
31-
});
32-
1+
(function () {
2+
3+
var callback = function () { return false; };
4+
5+
window.addEventListener('message', function (e) {
6+
switch (e.data.actionType) {
7+
case 'set-callback':
8+
callback = new Function(
9+
'user_id_str',
10+
'screen_name',
11+
'name',
12+
'text',
13+
'is_in_notification_area',
14+
'is_promotion',
15+
'is_retweet',
16+
'retweeter_user_id_str',
17+
'retweeter_screen_name',
18+
'retweeter_name',
19+
e.data.code
20+
);
21+
break;
22+
case 'go-callback':
23+
if (callback.apply({}, e.data.params)) {
24+
e.source.postMessage({
25+
actionType: 'tcm-remove-tweet',
26+
itemId: e.data.itemId,
27+
}, e.origin);
28+
}
29+
break;
30+
}
31+
});
32+
3333
})();

0 commit comments

Comments
 (0)