Sleazy Fork is available in English.

Fiction.Live Alert Blacklist

Automatically dismisses stories in the alerts that are blacklisted

  1. // ==UserScript==
  2. // @name Fiction.Live Alert Blacklist
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description Automatically dismisses stories in the alerts that are blacklisted
  6. // @author You
  7. // @match https://fiction.live/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. function myCode() {
  12. 'use strict';
  13.  
  14. var delayInMilliseconds = 200;
  15. var html = document.querySelector("html")
  16. //Blacklisted alert list
  17. var Blacklist = ["Placeholder",
  18. "Placeholder",
  19. "Placeholder",
  20. "Placeholder",
  21. "Placeholder"
  22. ]
  23. //Temporary, for things I may wish to read later
  24. var tempBlacklist = ["Placeholder"]
  25. var finalBlacklist = Blacklist.concat(tempBlacklist)
  26. 'use strict';
  27. alertHandler();
  28.  
  29.  
  30. /**
  31. * Simulate a click event.
  32. * @public
  33. * @param {Element} elem the element to simulate a click on
  34. */
  35. function simclick(elem) {
  36. // Create our event (with options)
  37. var evt = new MouseEvent('click', {
  38. bubbles: true,
  39. cancelable: true,
  40. view: window
  41. });
  42. // If cancelled, don't dispatch our event
  43. var canceled = !elem.dispatchEvent(evt);
  44. };
  45.  
  46.  
  47.  
  48.  
  49. //Delays the code by one second
  50. function alertHandler(){
  51.  
  52. //Gets every entry in the alert panel
  53. var alertsAll=document.querySelectorAll('[ng-repeat="item in type"]'), alertCount=0, currentAlert;
  54. var count = 0
  55. while (currentAlert = alertsAll[alertCount++])
  56. {
  57. //Adds to the counter
  58. count++
  59. //console.log(count)
  60. //Adds each alert into a variable
  61. var alertTitle = currentAlert.querySelector('[set-text="item.value.value"]');
  62.  
  63. //The actual value of the alert
  64. alertTitle.textContent
  65.  
  66. //Has the method ran for each item in the blacklist
  67. finalBlacklist.forEach(hideBlacklist);
  68.  
  69. }
  70.  
  71. function hideBlacklist(value) {
  72. //console.log(`"WHATS GOING ON ${value}"`);
  73. //Sets the var to current tag
  74. var alertCheck = (`${value} went live`);
  75. //If the tag was applied
  76. if(alertTitle.textContent == alertCheck) {
  77. console.log(value)
  78. console.log(alertTitle.textContent)
  79. console.log("This alert is blacklisted.");
  80. var dismiss = currentAlert.querySelector('[ng-click="dismissFeedItem(item)"]');
  81. simclick(dismiss);
  82. }
  83. /*
  84. if (alertCheck){
  85. //console.log("yes",bl2)
  86. //Hides any list items that have a blacklisted tag
  87. //currentAlert.style.display = "none";
  88. }
  89. */
  90. }}
  91. //document.body.style.backgroundColor = "grey"
  92. console.log("Alert Script Complete")
  93. setTimeout(alertHandler, delayInMilliseconds)
  94.  
  95. setInterval(alertHandler, 10000)
  96. };
  97.  
  98. var intervalDelay = 10000; //10 seconds
  99. setInterval(myCode, intervalDelay);