FB: Full Timestamps 2018

Shows full timestamps on Facebook posts

  1. // ==UserScript==
  2. // @name FB: Full Timestamps 2018
  3. // @match https://www.facebook.com/*
  4. // @match https://*.facebook.com/*
  5. // @match http://www.facebook.com/*
  6. // @match http://*.facebook.com/*
  7. // @run-at document-start
  8. // @grant GM_addStyle
  9. // @author wOxxOm & JZersche
  10. // @require https://gf.qytechs.cn/scripts/12228/code/setMutationHandler.js
  11. // @ require http://momentjs.com/downloads/moment.min.js
  12. // @ require https://momentjs.com/downloads/moment-with-locales.min.js
  13. // @version 3.00DEV
  14. // @namespace https://gf.qytechs.cn/users/95175
  15. // @description Shows full timestamps on Facebook posts
  16. // ==/UserScript==
  17.  
  18. var options = { weekday: 'long', year: 'numeric', month: 'numeric', day: '2-digit' };
  19.  
  20. GM_addStyle(
  21. '.full-timestamp { opacity: 0.95; color: #f00!important; }' +
  22. '.full-timestamp:hover { opacity: 1.0; }' +
  23. '.full-timestamp:before { content: ""; }' +
  24. '.full-timestamp:after { content: ""; }' +
  25. '.timestampContent {display: none; }' +
  26. '.savePostButton {position:relative!important; top:1px;left:50px; color:red !important;}'
  27. );
  28.  
  29. // process the already loaded portion of the page if any
  30. expandDates(document.querySelectorAll('abbr[data-utime]'));
  31.  
  32. // process the stuff added from now on
  33. setMutationHandler(document, 'abbr[data-utime]', expandDates);
  34. setMutationHandler(document, '._5pcq', expandPostIDs);
  35. setMutationHandler(document, '.r_1zif-zub1', savePostButton);
  36. setMutationHandler(document, '.r_1zif-zub1', ButtonEvents);
  37.  
  38. function expandDates(nodes) {
  39. for ( var i = 0, abbr; (abbr = nodes[i++]); ) {
  40. if (abbr.querySelector('.full-timestamp'))
  41. {
  42. // already processed
  43. continue;
  44. }
  45.  
  46. abbr.insertAdjacentHTML(
  47. 'beforeend', '<span class="full-timestamp">'
  48. + ' on ' + moment(new Date(abbr.dataset.utime * 1000)).format('M/DD/Y \\at LTS'));
  49. }
  50. }
  51.  
  52. function expandPostIDs(nodes) {
  53. for ( var i = 0; i < nodes.length; i++ )
  54. {
  55. var element = nodes[i];
  56. if(element.innerHTML.includes('<br>') === false && element.className === '_5pcq')
  57. {
  58. element.insertAdjacentHTML('beforeend', '<br>' +
  59. element.href.replace(/(&|\?)__xts__%5B0%5D=68.{0,240}/,'')
  60. .replace('permalink.php?','&nbsp;permalink.php?').replace('/groups/','Group: ')
  61. .replace('/permalink/','<br>Post ID: ').slice(24,100)
  62. .replace('/',''));
  63. }
  64. }
  65. }
  66.  
  67.  
  68. var Quote = '"';
  69. var sFunction = document.getElementsByClassName("brb")[0].style.backgroundColor = "red";
  70.  
  71.  
  72.  
  73. function savePostButton(nodes) {
  74. for ( var i = 0; i < nodes.length; i++ )
  75. {
  76. var element = nodes[i]; element.getElementsByClassName("r_1zif-zub1");
  77.  
  78. if(element.className == 'r_1zif-zub1')
  79. {
  80. element.insertAdjacentHTML(
  81. 'beforeend',
  82. '<input class="savePostButton" type="button"><br><span style="color:#09f!important;">Save Post</span></input>');
  83. }
  84. }
  85. }
  86.  
  87. function ButtonEvents(nodes) {
  88. // Start of Function
  89. for (var i = 0; i < nodes.length; i++)
  90. {
  91. var element = nodes[i];
  92. var getNodes = element.getElementsByClassName("savePostButton");
  93. if (getNodes) {element.addEventListener("click", ClickButton, false);}
  94. }
  95. // End Of Function
  96. }
  97.  
  98. // Button Action
  99. function ClickButton(nodes) {
  100. alert("clicked");
  101. }
  102. // End of Button Action Function
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110. /*
  111. var getMainNode = element.getElementsByClassName("_6a _43_1 _4f-9 _nws _21o- _fol");
  112. getMainNode[0];
  113. var createSpan = document.createElement("span");
  114. createSpan[0];
  115. var newButton = document.createElement("button");
  116. newButton[0];
  117. */

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址