|
1514 | 1514 | return { ...result, attr }; |
1515 | 1515 | } |
1516 | 1516 |
|
1517 | | - function injectBlockMenuItems(items, hasChannel, hasVideo, isLockupViewModel, storageData) { |
| 1517 | + function injectBlockMenuItems(items, hasChannel, hasVideo, isLockupViewModel, currentObj, storageData) { |
1518 | 1518 | if (isLockupViewModel) { |
1519 | | - return injectLockupViewModelButtons(items, hasChannel, hasVideo, storageData); |
| 1519 | + return injectLockupViewModelButtons(items, hasChannel, hasVideo, currentObj, storageData); |
1520 | 1520 | } else { |
1521 | 1521 | return injectStandardMenuButtons(items, hasChannel, hasVideo, storageData); |
1522 | 1522 | } |
1523 | 1523 | } |
1524 | 1524 |
|
1525 | | - function injectLockupViewModelButtons(items, hasChannel, hasVideo, storageData) { |
| 1525 | + function injectLockupViewModelButtons(items, hasChannel, hasVideo, currentObj, storageData) { |
1526 | 1526 | if (!items.length) return; |
1527 | 1527 |
|
1528 | | - const { removeItem: removeItemChannel, baseContext: cleanChannelContext } = createCleanContext(items, storageData, true); |
1529 | | - const { removeItem: removeItemVideo, baseContext: cleanVideoContext } = createCleanContext(items, storageData, false); |
| 1528 | + const cleanChannelContext = createCleanContext(items, storageData, true, currentObj); |
| 1529 | + const cleanVideoContext = createCleanContext(items, storageData, false, currentObj); |
1530 | 1530 |
|
1531 | 1531 | const blockChannelItem = createLockupButtonItem('Block Channel', cleanChannelContext); |
1532 | 1532 | const blockVideoItem = createLockupButtonItem('Block Video', cleanVideoContext); |
1533 | 1533 |
|
1534 | 1534 | if (hasChannel) items.push(blockChannelItem); |
1535 | 1535 | if (hasVideo) items.push(blockVideoItem); |
1536 | 1536 |
|
1537 | | - return removeItemChannel && removeItemVideo |
| 1537 | + return true; |
1538 | 1538 | } |
1539 | 1539 |
|
1540 | | - function createCleanContext(items, storageData, isChannel) { |
| 1540 | + function createCleanContext(items, storageData, isChannel, currentObj) { |
1541 | 1541 | const item = isChannel ? items[6] : items[5]; |
1542 | 1542 | if (storageData.options.block_feedback && item) { |
1543 | | - const baseContext = item?.listItemViewModel?.rendererContext; |
1544 | | - return {removeItem: false, baseContext}; |
| 1543 | + return item?.listItemViewModel?.rendererContext; |
1545 | 1544 | } |
1546 | 1545 |
|
1547 | 1546 | const baseContext = items[0]?.listItemViewModel?.rendererContext; |
1548 | 1547 | if (!baseContext) return null; |
1549 | | - |
1550 | | - const cleanContext = { ...baseContext }; |
1551 | | - // Prevent accidental execution |
1552 | | - if (cleanContext.commandContext?.onTap?.innertubeCommand?.signalServiceEndpoint) { |
1553 | | - cleanContext.commandContext.onTap.innertubeCommand.signalServiceEndpoint.actions = undefined; |
| 1548 | + |
| 1549 | + const msg = isChannel ? 'Channel Blocked' : 'Video Blocked'; |
| 1550 | + const cleanContext = deepClone(baseContext); |
| 1551 | + |
| 1552 | + if (cleanContext.commandContext?.onTap) { |
| 1553 | + let onTap = cleanContext.commandContext?.onTap; |
| 1554 | + onTap.innertubeCommand = { |
| 1555 | + "clickTrackingParams": "", |
| 1556 | + "commandMetadata": { |
| 1557 | + "webCommandMetadata": { |
| 1558 | + "sendPost": false, |
| 1559 | + "apiUrl": "" |
| 1560 | + } |
| 1561 | + }, |
| 1562 | + "feedbackEndpoint": { |
| 1563 | + "feedbackToken": "", |
| 1564 | + "uiActions": { |
| 1565 | + "hideEnclosingContainer": true |
| 1566 | + }, |
| 1567 | + "actions": [ |
| 1568 | + { |
| 1569 | + "clickTrackingParams": "", |
| 1570 | + "replaceEnclosingAction": { |
| 1571 | + "item": { |
| 1572 | + "notificationMultiActionRenderer": { |
| 1573 | + "responseText": { |
| 1574 | + "accessibility": { |
| 1575 | + "accessibilityData": { |
| 1576 | + "label": msg |
| 1577 | + } |
| 1578 | + }, |
| 1579 | + "simpleText": msg |
| 1580 | + }, |
| 1581 | + "buttons": [ |
| 1582 | + ], |
| 1583 | + "trackingParams": "", |
| 1584 | + "dismissalViewStyle": "DISMISSAL_VIEW_STYLE_COMPACT_TALL" |
| 1585 | + } |
| 1586 | + } |
| 1587 | + } |
| 1588 | + } |
| 1589 | + ], |
| 1590 | + "contentId": currentObj.contentId |
| 1591 | + } |
| 1592 | + } |
1554 | 1593 | } |
1555 | 1594 |
|
1556 | | - return {removeItem: true, baseContext: cleanContext}; |
| 1595 | + return cleanContext; |
1557 | 1596 | } |
1558 | 1597 |
|
1559 | 1598 | function createLockupButtonItem(title, rendererContext) { |
|
1614 | 1653 |
|
1615 | 1654 | const { items, hasChannel, hasVideo, isLockupViewModel, attr } = extracted; |
1616 | 1655 |
|
1617 | | - const removeItem = injectBlockMenuItems(items, hasChannel, hasVideo, isLockupViewModel, storageData); |
| 1656 | + injectBlockMenuItems(items, hasChannel, hasVideo, isLockupViewModel, obj[attr], storageData); |
1618 | 1657 |
|
1619 | 1658 | // Attach metadata only if needed |
1620 | 1659 | if (hasChannel || hasVideo) { |
1621 | 1660 | obj[attr]._btOriginalAttr = attr; |
1622 | 1661 | } |
1623 | | - |
1624 | | - if (isLockupViewModel && storageData.options.block_feedback && !removeItem) { |
1625 | | - const path = 'metadata.lockupMetadataViewModel.menuButton.buttonViewModel.onTap.innertubeCommand.showSheetCommand.panelLoadingStrategy.inlineContent.sheetViewModel'; |
1626 | | - const sheetmodel = getObjectByPath(obj[attr], path); |
1627 | | - if (sheetmodel?.blockTube?.metadata) |
1628 | | - sheetmodel.blockTube.metadata.removeObject = false; // Removing handled by yt |
1629 | | - } |
1630 | 1662 | } |
1631 | 1663 |
|
1632 | 1664 | function startHook() { |
|
1864 | 1896 | text: parentData.blockTube?.metadata?.videoName, |
1865 | 1897 | }; |
1866 | 1898 |
|
1867 | | - removeParent = parentData.blockTube?.metadata?.removeObject |
| 1899 | + removeParent = false |
1868 | 1900 | stopPlayer = false |
1869 | 1901 | } else { |
1870 | 1902 | const attrKey = parentData._btOriginalAttr; |
|
1939 | 1971 | return {}; |
1940 | 1972 | } |
1941 | 1973 |
|
1942 | | - parentDom = eventSink.parentComponent || eventSink.parentElement.__dataHost.hostElement; |
| 1974 | + parentDom = eventSink.parentComponent || eventSink.parentElement.__dataHost?.hostElement || eventSink.parentElement?.parentElement; |
1943 | 1975 | parentData = parentDom?.data; |
1944 | 1976 |
|
1945 | 1977 | if (!parentDom || !parentData) { |
|
1962 | 1994 | } else { |
1963 | 1995 | parentDom.remove(); |
1964 | 1996 | } |
1965 | | - } else if (isDataFromRightHandSide) { |
1966 | | - parentDom.parentNode.__dataHost.__restoreFocusNode.parentElement.parentElement.parentElement.parentElement.parentElement.remove() |
1967 | 1997 | } else { |
1968 | 1998 | parentDom.dismissedRenderer = { |
1969 | 1999 | notificationMultiActionRenderer: { |
|
0 commit comments