Skip to content

Commit 7a20307

Browse files
committed
flags
1 parent 1da6e5b commit 7a20307

2 files changed

Lines changed: 54 additions & 0 deletions

File tree

CleanX-user.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -721,6 +721,26 @@
721721
return;
722722
}
723723

724+
function addFlagOverlay(tweet, countryCode) {
725+
if (!countryCode) return;
726+
const flag = countryCodeToFlag(countryCode);
727+
if (!flag) return;
728+
const existingId = tweet.dataset.xcbOverlayId;
729+
if (existingId) {
730+
const existing = document.getElementById(existingId);
731+
if (existing) existing.remove();
732+
delete tweet.dataset.xcbOverlayId;
733+
}
734+
const overlay = document.createElement("div");
735+
const id = `xcb-overlay-${Math.random().toString(36).slice(2, 9)}`;
736+
overlay.id = id;
737+
overlay.textContent = flag;
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;";
740+
tweet.appendChild(overlay);
741+
tweet.dataset.xcbOverlayId = id;
742+
}
743+
724744
function renderFooterInfo(tweet, countryCode, usernameChanges) {
725745
const rowId = tweet.dataset.xcbFooterId;
726746
const hasCountry = Boolean(countryCode);
@@ -800,6 +820,12 @@
800820
tweet.style.position = tweet.dataset.xcbPrevPosition;
801821
delete tweet.dataset.xcbPrevPosition;
802822
}
823+
const overlayId = tweet.dataset.xcbOverlayId;
824+
if (overlayId) {
825+
const overlayEl = document.getElementById(overlayId);
826+
if (overlayEl) overlayEl.remove();
827+
delete tweet.dataset.xcbOverlayId;
828+
}
803829
tweet.style.removeProperty("outline");
804830
tweet.style.removeProperty("outline-offset");
805831
tweet.style.removeProperty("box-shadow");
@@ -857,6 +883,7 @@
857883
"position:absolute;top:-10px;left:-10px;background:#ff4d4f;color:#fff;padding:6px 10px;border-radius:10px;font-size:12px;font-weight:bold;box-shadow:0 4px 12px rgba(0,0,0,0.25);z-index:2;";
858884
tweet.appendChild(badge);
859885
tweet.dataset.xcbBadgeId = badgeId;
886+
addFlagOverlay(tweet, countryCode);
860887
}
861888

862889
function markRegionOnlyHighlight(tweet, regionName) {

extension/content.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -709,6 +709,26 @@
709709
return;
710710
}
711711

712+
function addFlagOverlay(tweet, countryCode) {
713+
if (!countryCode) return;
714+
const flag = countryCodeToFlag(countryCode);
715+
if (!flag) return;
716+
const existingId = tweet.dataset.xcbOverlayId;
717+
if (existingId) {
718+
const existing = document.getElementById(existingId);
719+
if (existing) existing.remove();
720+
delete tweet.dataset.xcbOverlayId;
721+
}
722+
const overlay = document.createElement("div");
723+
const id = `xcb-overlay-${Math.random().toString(36).slice(2, 9)}`;
724+
overlay.id = id;
725+
overlay.textContent = flag;
726+
overlay.style =
727+
"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;";
728+
tweet.appendChild(overlay);
729+
tweet.dataset.xcbOverlayId = id;
730+
}
731+
712732
function renderFooterInfo(tweet, countryCode, usernameChanges) {
713733
const rowId = tweet.dataset.xcbFooterId;
714734
const hasCountry = Boolean(countryCode);
@@ -788,6 +808,12 @@
788808
tweet.style.position = tweet.dataset.xcbPrevPosition;
789809
delete tweet.dataset.xcbPrevPosition;
790810
}
811+
const overlayId = tweet.dataset.xcbOverlayId;
812+
if (overlayId) {
813+
const overlayEl = document.getElementById(overlayId);
814+
if (overlayEl) overlayEl.remove();
815+
delete tweet.dataset.xcbOverlayId;
816+
}
791817
tweet.style.removeProperty("outline");
792818
tweet.style.removeProperty("outline-offset");
793819
tweet.style.removeProperty("box-shadow");
@@ -845,6 +871,7 @@
845871
"position:absolute;top:-10px;left:-10px;background:#ff4d4f;color:#fff;padding:6px 10px;border-radius:10px;font-size:12px;font-weight:bold;box-shadow:0 4px 12px rgba(0,0,0,0.25);z-index:2;";
846872
tweet.appendChild(badge);
847873
tweet.dataset.xcbBadgeId = badgeId;
874+
addFlagOverlay(tweet, countryCode);
848875
}
849876

850877
function markRegionOnlyHighlight(tweet, regionName) {

0 commit comments

Comments
 (0)