Skip to content

Instantly share code, notes, and snippets.

@Steve-Mr
Created September 25, 2025 07:12
Show Gist options
  • Select an option

  • Save Steve-Mr/69bd3d424a367d2974f8876afb820b61 to your computer and use it in GitHub Desktop.

Select an option

Save Steve-Mr/69bd3d424a367d2974f8876afb820b61 to your computer and use it in GitHub Desktop.
Telegram Web K Stories Blocker
// ==UserScript==
// @name Telegram Web K Stories Blocker
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Block Stories feature in Telegram Web K
// @match https://web.telegram.org/k/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
// 方案1:移除 Stories 容器
function removeStories() {
const storiesContainer = document.querySelector('.stories-list');
if (storiesContainer) {
storiesContainer.remove();
}
}
// 方案2:阻止滚动行为和动画
function blockStoriesScroll() {
const style = document.createElement('style');
style.textContent = `
.stories-list {
display: none !important;
height: 0 !important;
overflow: hidden !important;
pointer-events: none !important;
}
.ListContainer {
transform: none !important;
transition: none !important;
}
`;
document.head.appendChild(style);
}
// 方案3:拦截相关API调用
function interceptStoriesAPI() {
if (window.rootScope && window.rootScope.managers) {
// 拦截 stories 管理器的方法
const original = window.rootScope.managers.appStoriesManager;
if (original) {
window.rootScope.managers.appStoriesManager = new Proxy(original, {
get: function(target, prop) {
const value = target[prop];
if (typeof value === 'function') {
return function(...args) {
// 返回空数组或空对象,模拟无 stories 状态
return Promise.resolve([]);
};
}
return value;
}
});
}
}
}
// 监听 DOM 变化,确保在动态加载时也能生效
const observer = new MutationObserver(() => {
removeStories();
blockStoriesScroll();
});
// 启动监听
observer.observe(document.body, {
childList: true,
subtree: true
});
// 初始执行
removeStories();
blockStoriesScroll();
interceptStoriesAPI();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment