Skip to content
This repository has been archived by the owner on Sep 6, 2024. It is now read-only.

Commit

Permalink
fix #4
Browse files Browse the repository at this point in the history
  • Loading branch information
sir.kokabi committed Jun 29, 2024
1 parent 4492974 commit 40e98d4
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 9 deletions.
Binary file added assets/Vazirmatn.ttf
Binary file not shown.
16 changes: 14 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"moment-hijri": "^2.1.2",
"moment-jalaali": "^0.10.0",
"persian-rex": "^2.3.3",
"plasmo": "0.84.2",
"plasmo": "0.84.0",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-icons": "^4.12.0",
Expand All @@ -28,5 +28,17 @@
"@types/react-dom": "18.2.18",
"postcss": "^8.4.38",
"tailwindcss": "^3.4.4"
},
"manifest": {
"web_accessible_resources": [
{
"resources": [
"Vazirmatn.ttf"
],
"matches": [
"https://x.com/*"
]
}
]
}
}
}
8 changes: 4 additions & 4 deletions src/contents/ProfileNote.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const ProfileNote = () => {
const isNoteChanged = note !== originalNote;

return (
<div className="relative w-full">
<div className="relative w-full font-[Vazirmatn]">
<textarea
className="w-full shadow-[0px_2px_3px_-1px_rgba(0,0,0,0.1),0px_1px_0px_0px_rgba(25,28,33,0.02),0px_0px_0px_1px_rgba(25,28,33,0.08)] p-3 rounded-md mt-2"
style={{ direction: isPersian ? "rtl" : "ltr", border: "none" }}
Expand All @@ -78,18 +78,18 @@ const ProfileNote = () => {
{isNoteChanged && (
<>
<button
className={`mt-2 px-4 py-1 bg-[#299cee] text-white rounded ${isPersian ? 'mr-auto' : 'ml-auto'} block`}
className={`mt-2 px-4 pt-1 bg-[#299cee] text-white rounded ${isPersian ? 'mr-auto' : 'ml-auto'} block`}
onClick={saveNote}
>
Save
</button>
<div className={`absolute bottom-2 ${isPersian ? 'right-2' : 'left-2'} text-xs px-2 py-1`}>
<div className={`absolute bottom-2 ${isPersian ? 'right-0' : 'left-0'} text-xs px-2 py-1`}>
{remainingLength}
</div>
</>
)}
{showToast && (
<div className={`absolute bottom-2 ${isPersian ? 'left-2' : 'right-2'} text-xs px-2 py-1`}>
<div className={`absolute bottom-2 ${isPersian ? 'left-0' : 'right-0'} text-xs px-2 py-1`}>
Saved
</div>
)}
Expand Down
5 changes: 3 additions & 2 deletions src/contents/ProfileNoteAlert.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ const ProfileNoteAlert = ({anchor}) => {
const [isPersian, setIsPersian] = useState(false);

const username = anchor.element.querySelector('div[data-testid="User-Name"] > div:nth-child(2) > div > div').textContent.replace("@","");

useEffect(() => {

utils.getProfileNote(username).then((value) => {
if (typeof value === 'string' && value.trim() !== ''){
setNote(value);
Expand All @@ -36,7 +37,7 @@ const ProfileNoteAlert = ({anchor}) => {


return (
<span title={note} style={{ direction: isPersian ? "rtl" : "ltr", border: "none" }} className="font-bold text-sm">
<span title={note} style={{ direction: isPersian ? "rtl" : "ltr", border: "none", fontFamily:"Vazirmatn" }} className="font-light text-sm">
{truncateString(note, 50)}
</span>
);
Expand Down
19 changes: 18 additions & 1 deletion src/contents/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,26 @@ import {
import * as utils from "~utils"

export const config = {
matches: ["https://twitter.com/*", "https://x.com/*"]
matches: ["https://twitter.com/*", "https://x.com/*"],
}

// Create a style element
var fa = document.createElement('style');
fa.textContent = `
@font-face {
font-family: 'Vazirmatn';
src: url('${chrome.runtime.getURL('Vazirmatn.ttf')}') format('truetype');
font-weight: 100 900;;
}
div[data-testid="tweetText"], [data-testid="UserDescription"] {
font-family: Vazirmatn, TwitterChirp, sans-serif !important;
font-weight: 400;
}
`;

// Append the style element to the document head
document.head.appendChild(fa);

const items = [
//global
{
Expand Down

0 comments on commit 40e98d4

Please sign in to comment.