Skip to content

Commit c2ae4d3

Browse files
authored
Add files via upload
1 parent a429d99 commit c2ae4d3

File tree

8 files changed

+740
-0
lines changed

8 files changed

+740
-0
lines changed

background.js

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
2+
3+
chrome.runtime.onMessage.addListener((msg, sender, sendResponse) => {
4+
if (msg.action === 'sendNote') {
5+
handleSendNote(msg.payload).then(sendResponse);
6+
return true;
7+
}
8+
});
9+
10+
async function handleSendNote({ cookieStr, csrftoken, ds_user_id, noteText, textColor, bgColor, audience }) {
11+
try {
12+
13+
const variables = JSON.stringify({
14+
input: {
15+
actor_id: ds_user_id,
16+
client_mutation_id: "1",
17+
inbox_tray_item_type: "note",
18+
audience: audience,
19+
additional_params: {
20+
note_create_params: {
21+
note_style: 0,
22+
note_customization: {
23+
text_color_hex: textColor,
24+
secondary_text_color_hex: "#f8f9f9",
25+
customization_id: null,
26+
custom_emoji: null,
27+
background_color_hex: bgColor
28+
},
29+
note_creation_source: 1,
30+
text: noteText,
31+
external_attribution_url: null
32+
}
33+
}
34+
},
35+
should_fetch_friend_map_entrypoint: false,
36+
is_location_likes_v2_enabled: false,
37+
should_fetch_friend_map_user: false
38+
});
39+
40+
const body = new URLSearchParams({
41+
av: ds_user_id,
42+
__d: 'www',
43+
__user: '0',
44+
__a: '1',
45+
__req: '1',
46+
dpr: '1',
47+
__ccg: 'GOOD',
48+
fb_api_caller_class: 'RelayModern',
49+
fb_api_req_friendly_name: 'usePolarisCreateInboxTrayItemSubmitMutation',
50+
variables,
51+
server_timestamps: 'true',
52+
doc_id: '25155183657506484',
53+
});
54+
55+
const response = await fetch('https://www.instagram.com/graphql/query', {
56+
method: 'POST',
57+
headers: {
58+
'accept': '*/*',
59+
'accept-language': 'en,ar;q=0.9',
60+
'content-type': 'application/x-www-form-urlencoded',
61+
'origin': 'https://www.instagram.com',
62+
'referer': 'https://www.instagram.com/',
63+
'x-csrftoken': csrftoken,
64+
'x-ig-app-id': '936619743392459',
65+
'x-fb-friendly-name': 'usePolarisCreateInboxTrayItemSubmitMutation',
66+
'cookie': cookieStr,
67+
},
68+
body: body.toString()
69+
});
70+
71+
const data = await response.json();
72+
73+
74+
if (data.errors && data.errors.length > 0) {
75+
return { success: false, error: data.errors[0].message || 'Instagram API error' };
76+
}
77+
78+
if (data.data?.xdt_create_inbox_tray_item) {
79+
return { success: true };
80+
}
81+
82+
83+
if (response.ok) {
84+
return { success: true };
85+
}
86+
87+
return { success: false, error: 'Unexpected response from Instagram' };
88+
89+
} catch (err) {
90+
return { success: false, error: err.message };
91+
}
92+
}

content.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
2+
// ked
3+
4+
(function () {
5+
6+
chrome.runtime.onMessage.addListener((msg, sender, sendResponse) => {
7+
if (msg.action === 'getPageTokens') {
8+
9+
const metaTags = document.querySelectorAll('meta');
10+
let tokens = {};
11+
metaTags.forEach(m => {
12+
if (m.name === 'csrf-token') tokens.csrf = m.content;
13+
});
14+
sendResponse(tokens);
15+
}
16+
});
17+
})();

icons/icon128.png

8.75 KB
Loading

icons/icon16.png

525 Bytes
Loading

icons/icon48.png

2.27 KB
Loading

manifest.json

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"manifest_version": 3,
3+
"name": "NoteStyle",
4+
"version": "1.0",
5+
"description": "Custom Instagram Notes",
6+
"permissions": [
7+
"cookies",
8+
"storage",
9+
"activeTab",
10+
"scripting"
11+
],
12+
"host_permissions": [
13+
"https://www.instagram.com/*",
14+
"*://*.instagram.com/*"
15+
],
16+
"action": {
17+
"default_popup": "popup.html",
18+
"default_icon": {
19+
"16": "icons/icon16.png",
20+
"48": "icons/icon48.png",
21+
"128": "icons/icon128.png"
22+
}
23+
},
24+
"background": {
25+
"service_worker": "background.js"
26+
},
27+
"content_scripts": [
28+
{
29+
"matches": [
30+
"https://www.instagram.com/*"
31+
],
32+
"js": [
33+
"content.js"
34+
],
35+
"run_at": "document_idle"
36+
}
37+
]
38+
}

0 commit comments

Comments
 (0)