|
736 | 736 | overlay.id = id; |
737 | 737 | overlay.textContent = flag; |
738 | 738 | overlay.style = |
739 | | - "position:absolute;inset:0;display:flex;align-items:center;justify-content:center;font-size:96px;opacity:0.08;pointer-events:none;user-select:none;filter:saturate(0.9);z-index:1;"; |
| 739 | + "position:absolute;inset:0;display:flex;align-items:center;justify-content:center;font-size:220px;opacity:0.11;pointer-events:none;user-select:none;filter:saturate(0.9);z-index:1;overflow:hidden;line-height:1;"; |
| 740 | + overlay.style.width = "100%"; |
| 741 | + overlay.style.height = "100%"; |
| 742 | + overlay.style.transform = "scale(1.1)"; |
740 | 743 | tweet.appendChild(overlay); |
741 | 744 | tweet.dataset.xcbOverlayId = id; |
742 | 745 | } |
|
866 | 869 | tweet.dataset.xcbPrevPosition = tweet.style.position || ""; |
867 | 870 | tweet.style.position = "relative"; |
868 | 871 | } |
869 | | - tweet.style.setProperty("outline", "3px solid #ff4d4f", "important"); |
| 872 | + const palette = flagPalette(countryCode); |
| 873 | + tweet.style.setProperty( |
| 874 | + "outline", |
| 875 | + `3px solid ${palette.primary}`, |
| 876 | + "important", |
| 877 | + ); |
870 | 878 | tweet.style.setProperty("outline-offset", "2px", "important"); |
871 | 879 | tweet.style.setProperty( |
872 | 880 | "box-shadow", |
873 | | - "0 0 0 3px rgba(255,77,79,0.35)", |
| 881 | + `0 0 0 3px ${palette.shadow}`, |
874 | 882 | "important", |
875 | 883 | ); |
876 | | - tweet.style.setProperty("background-color", "rgba(255,77,79,0.12)", "important"); |
| 884 | + tweet.style.setProperty("background-color", palette.background, "important"); |
877 | 885 |
|
878 | 886 | const badge = document.createElement("div"); |
879 | 887 | const badgeId = `xcb-badge-${Math.random().toString(36).slice(2, 9)}`; |
|
1289 | 1297 | btn.setAttribute("role", "button"); |
1290 | 1298 | btn.href = "javascript:void(0)"; |
1291 | 1299 | btn.innerHTML = |
1292 | | - '<span class="xcb-icon" style="font-size:22px;line-height:22px;color:#fff;">🚫</span><span class="xcb-label" style="font-size:18px;font-weight:700;">Blocker</span>'; |
| 1300 | + '<span class="xcb-icon" style="font-size:22px;line-height:22px;color:#fff;">🚫</span><span class="xcb-label" style="font-size:18px;font-weight:700;">CleanX</span>'; |
1293 | 1301 | btn.style = |
1294 | 1302 | "display:flex;align-items:center;gap:14px;padding:12px;border-radius:9999px;color:#e7e9ea;text-decoration:none;font-size:17px;font-weight:700;cursor:pointer;max-width:260px;min-width:52px;box-sizing:border-box;"; |
1295 | 1303 | btn.onmouseenter = () => { |
|
1310 | 1318 | } |
1311 | 1319 | }; |
1312 | 1320 | const label = btn.querySelector(".xcb-label"); |
1313 | | - if (label) { |
| 1321 | + const updateLabelVisibility = () => { |
| 1322 | + if (!label) return; |
1314 | 1323 | label.style.display = |
1315 | 1324 | (nav.getBoundingClientRect().width || 0) > 80 ? "inline" : "none"; |
| 1325 | + }; |
| 1326 | + updateLabelVisibility(); |
| 1327 | + if (typeof ResizeObserver !== "undefined") { |
| 1328 | + const ro = new ResizeObserver(updateLabelVisibility); |
| 1329 | + ro.observe(nav); |
| 1330 | + } else { |
| 1331 | + window.addEventListener("resize", updateLabelVisibility); |
1316 | 1332 | } |
1317 | 1333 | if (btn.parentElement !== parent) { |
1318 | 1334 | if (moreEntry && moreEntry.parentElement === parent) { |
|
1593 | 1609 | "X Country Blocker v5.1 (CLEAN) ready — nothing blocked until you add it", |
1594 | 1610 | ); |
1595 | 1611 | })(); |
| 1612 | + function flagPalette(code) { |
| 1613 | + const c = (code || "").toUpperCase(); |
| 1614 | + const table = { |
| 1615 | + US: { primary: "#b22234", secondary: "#3c3b6e" }, |
| 1616 | + CA: { primary: "#d52b1e", secondary: "#ffffff" }, |
| 1617 | + GB: { primary: "#c8102e", secondary: "#012169" }, |
| 1618 | + FR: { primary: "#0055a4", secondary: "#ef4135" }, |
| 1619 | + DE: { primary: "#000000", secondary: "#d00" }, |
| 1620 | + IT: { primary: "#009246", secondary: "#ce2b37" }, |
| 1621 | + ES: { primary: "#aa151b", secondary: "#f1bf00" }, |
| 1622 | + NL: { primary: "#ae1c28", secondary: "#21468b" }, |
| 1623 | + SE: { primary: "#006aa7", secondary: "#fecc00" }, |
| 1624 | + NO: { primary: "#ba0c2f", secondary: "#00205b" }, |
| 1625 | + FI: { primary: "#003580", secondary: "#ffffff" }, |
| 1626 | + DK: { primary: "#c8102e", secondary: "#ffffff" }, |
| 1627 | + RU: { primary: "#0039a6", secondary: "#d52b1e" }, |
| 1628 | + UA: { primary: "#0057b7", secondary: "#ffd700" }, |
| 1629 | + PL: { primary: "#dc143c", secondary: "#ffffff" }, |
| 1630 | + CN: { primary: "#de2910", secondary: "#ffde00" }, |
| 1631 | + JP: { primary: "#ffffff", secondary: "#bc002d" }, |
| 1632 | + KR: { primary: "#003478", secondary: "#c60c30" }, |
| 1633 | + AU: { primary: "#00247d", secondary: "#ff0000" }, |
| 1634 | + NZ: { primary: "#00247d", secondary: "#ff0000" }, |
| 1635 | + BR: { primary: "#009c3b", secondary: "#ffdf00" }, |
| 1636 | + MX: { primary: "#006341", secondary: "#ce1126" }, |
| 1637 | + AR: { primary: "#74acdf", secondary: "#f6b40e" }, |
| 1638 | + IN: { primary: "#ff9933", secondary: "#128807" }, |
| 1639 | + SA: { primary: "#006c35", secondary: "#ffffff" }, |
| 1640 | + IL: { primary: "#0038b8", secondary: "#ffffff" }, |
| 1641 | + IR: { primary: "#239f40", secondary: "#da0000" }, |
| 1642 | + TR: { primary: "#e30a17", secondary: "#ffffff" }, |
| 1643 | + ZA: { primary: "#007749", secondary: "#ffb612" }, |
| 1644 | + NG: { primary: "#008753", secondary: "#ffffff" }, |
| 1645 | + KE: { primary: "#006600", secondary: "#b22222" }, |
| 1646 | + EG: { primary: "#ce1126", secondary: "#000000" }, |
| 1647 | + ID: { primary: "#ce1126", secondary: "#ffffff" }, |
| 1648 | + PH: { primary: "#0038a8", secondary: "#ce1126" }, |
| 1649 | + SG: { primary: "#e0001b", secondary: "#ffffff" }, |
| 1650 | + TH: { primary: "#2d2a4a", secondary: "#a51931" }, |
| 1651 | + VN: { primary: "#da251d", secondary: "#ffde00" }, |
| 1652 | + }; |
| 1653 | + const entry = table[c] || table[(c || "").slice(0, 2)] || { |
| 1654 | + primary: "#ff4d4f", |
| 1655 | + secondary: "#ffffff", |
| 1656 | + }; |
| 1657 | + return { |
| 1658 | + primary: entry.primary, |
| 1659 | + secondary: entry.secondary, |
| 1660 | + shadow: `${entry.primary}55`, |
| 1661 | + background: `${entry.secondary}1f`, |
| 1662 | + }; |
| 1663 | + } |
0 commit comments