Skip to content

Commit 86e70ef

Browse files
committed
init
1 parent 8f802cb commit 86e70ef

File tree

4 files changed

+101
-0
lines changed

4 files changed

+101
-0
lines changed

background.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
chrome.webRequest.onCompleted.addListener(onRequestCompleted,
2+
{ urls: ["https://draft.blogger.com/_/BloggerUi/data/*"], types: ["xmlhttprequest"] }
3+
);
4+
5+
function onRequestCompleted(details) {
6+
7+
if (!details.url.includes('rpcids=ZmRkFc')) return;
8+
9+
let notifId = '1';
10+
const notificationOptions = {
11+
type: 'basic',
12+
iconUrl: "data:image/webp;base64,UklGRiIBAABXRUJQVlA4TBUBAAAvH8AHAH/AJgDAJNMo6/8vjbsb8FHDSCQp675/ETKhUCgKoCaSFGlsIB5JaCCnyN7Lbv4D4P/flT5lC5QSUOHABniGRfBybZ80y3YB3GrblidVBviti2eYtPrEPQE2YIPICqwQrdA3UlH9tFRU7u5u3/viA0T0fwK0f9Jz/pVzzfO59ZfTkxXnJ9bzKBRgO6URWFtYz3CzTm50XQBwXYDNrGfGjwDGj1jmCOKsUxnCEQbgCANSSAkBa0ywDHU6EOeaU6g1gfpMfJWpx2FpwMQUmBGAWhPqJ8RtZfyVc2SkWaXQIoEIbk17fV0iZZbaD2m3pmlaf4nUdsv9ypy3WkTUbh1o4mu/1Wq1DtySdv56enLi1v5HAA==",
13+
title: `Template updated`,
14+
message: ``,
15+
requireInteraction: true,
16+
};
17+
chrome.notifications.create(notifId, notificationOptions);
18+
19+
setTimeout(function() {
20+
chrome.notifications.clear(notifId);
21+
}, 2000);
22+
23+
}

inject.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
function initTools() {
2+
3+
let editorEl = document.querySelector('iframe.editable');
4+
if (!editorEl) return;
5+
if (editorEl.dataset.isToolsLoaded) return;
6+
7+
attachKeyboardListeners();
8+
}
9+
10+
function attachKeyboardListeners() {
11+
12+
let editorEl = document.querySelector('iframe.editable');
13+
editorEl.dataset.isToolsLoaded = true;
14+
15+
// set format block
16+
editorEl.contentDocument.documentElement.addEventListener('keydown', function(event) {
17+
if (event.ctrlKey && event.shiftKey && event.key === '!') {
18+
event.preventDefault();
19+
editorEl.contentDocument.execCommand('formatBlock', false, 'p');
20+
}
21+
});
22+
23+
24+
// set background color
25+
editorEl.contentDocument.documentElement.addEventListener('keydown', function(event) {
26+
if (event.ctrlKey && event.key === 'm') {
27+
event.preventDefault();
28+
document.querySelector('iframe.editable').contentDocument.execCommand('backColor', false, '#fcff01');
29+
}
30+
});
31+
}
32+
33+
34+
// observe visibility change
35+
document.addEventListener('visibilitychange', initTools, true);
36+
initTools();

manifest.json

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"name": "Blogger Dashboard Utility",
3+
"description": "Utilities for Blogger template developer and blog author.",
4+
"version": "1.0",
5+
"manifest_version": 3,
6+
"permissions": [
7+
"notifications",
8+
"webRequest"
9+
],
10+
"host_permissions": [
11+
"*://*.blogger.com/_/BloggerUi/data/*"
12+
],
13+
"background": {
14+
"service_worker": "background.js"
15+
},
16+
"content_scripts": [
17+
{
18+
"matches": [
19+
"https://*.blogger.com/blog/post/edit/*"
20+
],
21+
"js": [
22+
"inject.js"
23+
]
24+
},
25+
{
26+
"all_frames": true,
27+
"matches": [
28+
"*://*.blogger.com/display*"
29+
],
30+
"css": [
31+
"style.css"
32+
]
33+
}
34+
]
35+
}

style.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#layout .widget::after {
2+
content: attr(id);
3+
left: 0;
4+
display: block;
5+
text-align: left;
6+
margin-top: 5px;
7+
}

0 commit comments

Comments
 (0)